id
int32
0
58k
repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
sequence
docstring
stringlengths
4
11.8k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
86
226
57,600
VasoBolkvadze/noderaven
index.js
function (db, indexName, whereClause, groupBy, fieldsToSum, cb) { var url = host + 'databases/' + db + '/facets/' + indexName + '?'; url += whereClause ? '&query=' + encodeURIComponent(whereClause) : ''; url += '&facetStart=0&facetPageSize=1024'; var facets = fieldsToSum .map(function (field) { return { "Mode": 0, "Aggregation": 16, "AggregationField": field, "Name": groupBy, "DisplayName": field, "Ranges": [], "MaxResults": null, "TermSortMode": 0, "IncludeRemainingTerms": false }; }); url += '&facets=' + JSON.stringify(facets); request(url, function (error, response, body) { if (!error && response.statusCode === 200) { var result = JSON.parse(body); cb(null, result); } else { cb(error || new Error(response.statusCode), null); } }); }
javascript
function (db, indexName, whereClause, groupBy, fieldsToSum, cb) { var url = host + 'databases/' + db + '/facets/' + indexName + '?'; url += whereClause ? '&query=' + encodeURIComponent(whereClause) : ''; url += '&facetStart=0&facetPageSize=1024'; var facets = fieldsToSum .map(function (field) { return { "Mode": 0, "Aggregation": 16, "AggregationField": field, "Name": groupBy, "DisplayName": field, "Ranges": [], "MaxResults": null, "TermSortMode": 0, "IncludeRemainingTerms": false }; }); url += '&facets=' + JSON.stringify(facets); request(url, function (error, response, body) { if (!error && response.statusCode === 200) { var result = JSON.parse(body); cb(null, result); } else { cb(error || new Error(response.statusCode), null); } }); }
[ "function", "(", "db", ",", "indexName", ",", "whereClause", ",", "groupBy", ",", "fieldsToSum", ",", "cb", ")", "{", "var", "url", "=", "host", "+", "'databases/'", "+", "db", "+", "'/facets/'", "+", "indexName", "+", "'?'", ";", "url", "+=", "whereClause", "?", "'&query='", "+", "encodeURIComponent", "(", "whereClause", ")", ":", "''", ";", "url", "+=", "'&facetStart=0&facetPageSize=1024'", ";", "var", "facets", "=", "fieldsToSum", ".", "map", "(", "function", "(", "field", ")", "{", "return", "{", "\"Mode\"", ":", "0", ",", "\"Aggregation\"", ":", "16", ",", "\"AggregationField\"", ":", "field", ",", "\"Name\"", ":", "groupBy", ",", "\"DisplayName\"", ":", "field", ",", "\"Ranges\"", ":", "[", "]", ",", "\"MaxResults\"", ":", "null", ",", "\"TermSortMode\"", ":", "0", ",", "\"IncludeRemainingTerms\"", ":", "false", "}", ";", "}", ")", ";", "url", "+=", "'&facets='", "+", "JSON", ".", "stringify", "(", "facets", ")", ";", "request", "(", "url", ",", "function", "(", "error", ",", "response", ",", "body", ")", "{", "if", "(", "!", "error", "&&", "response", ".", "statusCode", "===", "200", ")", "{", "var", "result", "=", "JSON", ".", "parse", "(", "body", ")", ";", "cb", "(", "null", ",", "result", ")", ";", "}", "else", "{", "cb", "(", "error", "||", "new", "Error", "(", "response", ".", "statusCode", ")", ",", "null", ")", ";", "}", "}", ")", ";", "}" ]
Generates and returns Dynamic Report. @param {string} db @param {string} indexName @param {string} whereClause @param {string} groupBy @param {Array<string>} fieldsToSum @param {Function} cb
[ "Generates", "and", "returns", "Dynamic", "Report", "." ]
62353a62f634be90f7aa4c36f19574ecd720b463
https://github.com/VasoBolkvadze/noderaven/blob/62353a62f634be90f7aa4c36f19574ecd720b463/index.js#L224-L251
57,601
VasoBolkvadze/noderaven
index.js
function (db, id, wantedPropsFromMetadata, cb) { if(Object.prototype.toString.call(wantedPropsFromMetadata) == '[object Function]'){ cb = wantedPropsFromMetadata; wantedPropsFromMetadata = []; } var url = host + 'databases/' + db + '/docs/' + id; request(url, function (error, response, body) { if(error || response.statusCode != 200) return cb(error || new Error(response.statusCode)); var doc = JSON.parse(body); var meta = _.reduce(response.headers , function (memo, val, key) { if (key.indexOf('raven') === 0 || wantedPropsFromMetadata.indexOf(key) != -1) memo[key] = val; return memo; }, {}); meta['@id'] = response.headers['__document_id']; meta.etag = response.headers['etag']; meta.dateCreated = response.headers['DateCreated'] || response.headers['datecreated']; doc['@metadata'] = meta; cb(null, doc); }); }
javascript
function (db, id, wantedPropsFromMetadata, cb) { if(Object.prototype.toString.call(wantedPropsFromMetadata) == '[object Function]'){ cb = wantedPropsFromMetadata; wantedPropsFromMetadata = []; } var url = host + 'databases/' + db + '/docs/' + id; request(url, function (error, response, body) { if(error || response.statusCode != 200) return cb(error || new Error(response.statusCode)); var doc = JSON.parse(body); var meta = _.reduce(response.headers , function (memo, val, key) { if (key.indexOf('raven') === 0 || wantedPropsFromMetadata.indexOf(key) != -1) memo[key] = val; return memo; }, {}); meta['@id'] = response.headers['__document_id']; meta.etag = response.headers['etag']; meta.dateCreated = response.headers['DateCreated'] || response.headers['datecreated']; doc['@metadata'] = meta; cb(null, doc); }); }
[ "function", "(", "db", ",", "id", ",", "wantedPropsFromMetadata", ",", "cb", ")", "{", "if", "(", "Object", ".", "prototype", ".", "toString", ".", "call", "(", "wantedPropsFromMetadata", ")", "==", "'[object Function]'", ")", "{", "cb", "=", "wantedPropsFromMetadata", ";", "wantedPropsFromMetadata", "=", "[", "]", ";", "}", "var", "url", "=", "host", "+", "'databases/'", "+", "db", "+", "'/docs/'", "+", "id", ";", "request", "(", "url", ",", "function", "(", "error", ",", "response", ",", "body", ")", "{", "if", "(", "error", "||", "response", ".", "statusCode", "!=", "200", ")", "return", "cb", "(", "error", "||", "new", "Error", "(", "response", ".", "statusCode", ")", ")", ";", "var", "doc", "=", "JSON", ".", "parse", "(", "body", ")", ";", "var", "meta", "=", "_", ".", "reduce", "(", "response", ".", "headers", ",", "function", "(", "memo", ",", "val", ",", "key", ")", "{", "if", "(", "key", ".", "indexOf", "(", "'raven'", ")", "===", "0", "||", "wantedPropsFromMetadata", ".", "indexOf", "(", "key", ")", "!=", "-", "1", ")", "memo", "[", "key", "]", "=", "val", ";", "return", "memo", ";", "}", ",", "{", "}", ")", ";", "meta", "[", "'@id'", "]", "=", "response", ".", "headers", "[", "'__document_id'", "]", ";", "meta", ".", "etag", "=", "response", ".", "headers", "[", "'etag'", "]", ";", "meta", ".", "dateCreated", "=", "response", ".", "headers", "[", "'DateCreated'", "]", "||", "response", ".", "headers", "[", "'datecreated'", "]", ";", "doc", "[", "'@metadata'", "]", "=", "meta", ";", "cb", "(", "null", ",", "doc", ")", ";", "}", ")", ";", "}" ]
Loads document with given id. @param {string} db @param {string} id @param {string} wantedPropsFromMetadata(OPTIONAL) @param {Function} cb
[ "Loads", "document", "with", "given", "id", "." ]
62353a62f634be90f7aa4c36f19574ecd720b463
https://github.com/VasoBolkvadze/noderaven/blob/62353a62f634be90f7aa4c36f19574ecd720b463/index.js#L258-L280
57,602
VasoBolkvadze/noderaven
index.js
function (db, id, doc, metadata, cb) { var operations = [ { Method: "PUT", Document: doc, Metadata: metadata, Key: id } ]; request.post({ url: host + 'databases/' + db + '/bulk_docs', headers: { 'Content-Type': 'application/json; charset=utf-8' }, body: JSON.stringify(operations) }, function (error, response, resBody) { if (!error && response.statusCode === 200) { var result = JSON.parse(resBody); cb(null, result); } else { cb(error || new Error(response.statusCode), null); } }); }
javascript
function (db, id, doc, metadata, cb) { var operations = [ { Method: "PUT", Document: doc, Metadata: metadata, Key: id } ]; request.post({ url: host + 'databases/' + db + '/bulk_docs', headers: { 'Content-Type': 'application/json; charset=utf-8' }, body: JSON.stringify(operations) }, function (error, response, resBody) { if (!error && response.statusCode === 200) { var result = JSON.parse(resBody); cb(null, result); } else { cb(error || new Error(response.statusCode), null); } }); }
[ "function", "(", "db", ",", "id", ",", "doc", ",", "metadata", ",", "cb", ")", "{", "var", "operations", "=", "[", "{", "Method", ":", "\"PUT\"", ",", "Document", ":", "doc", ",", "Metadata", ":", "metadata", ",", "Key", ":", "id", "}", "]", ";", "request", ".", "post", "(", "{", "url", ":", "host", "+", "'databases/'", "+", "db", "+", "'/bulk_docs'", ",", "headers", ":", "{", "'Content-Type'", ":", "'application/json; charset=utf-8'", "}", ",", "body", ":", "JSON", ".", "stringify", "(", "operations", ")", "}", ",", "function", "(", "error", ",", "response", ",", "resBody", ")", "{", "if", "(", "!", "error", "&&", "response", ".", "statusCode", "===", "200", ")", "{", "var", "result", "=", "JSON", ".", "parse", "(", "resBody", ")", ";", "cb", "(", "null", ",", "result", ")", ";", "}", "else", "{", "cb", "(", "error", "||", "new", "Error", "(", "response", ".", "statusCode", ")", ",", "null", ")", ";", "}", "}", ")", ";", "}" ]
Overwrites given document with given id. @param {string} db @param {string} id @param {Object} doc @param {Object} metadata @param {Function} cb
[ "Overwrites", "given", "document", "with", "given", "id", "." ]
62353a62f634be90f7aa4c36f19574ecd720b463
https://github.com/VasoBolkvadze/noderaven/blob/62353a62f634be90f7aa4c36f19574ecd720b463/index.js#L288-L311
57,603
VasoBolkvadze/noderaven
index.js
function (db, id, operations, cb) { request.patch({ url: host + 'databases/' + db + '/docs/' + id, headers: { 'Content-Type': 'application/json; charset=utf-8' }, body: JSON.stringify(operations) }, function (error, response, resBody) { if (!error && response.statusCode === 200) { var result = JSON.parse(resBody); cb(null, result); } else { cb(error || new Error(response.statusCode), null); } }); }
javascript
function (db, id, operations, cb) { request.patch({ url: host + 'databases/' + db + '/docs/' + id, headers: { 'Content-Type': 'application/json; charset=utf-8' }, body: JSON.stringify(operations) }, function (error, response, resBody) { if (!error && response.statusCode === 200) { var result = JSON.parse(resBody); cb(null, result); } else { cb(error || new Error(response.statusCode), null); } }); }
[ "function", "(", "db", ",", "id", ",", "operations", ",", "cb", ")", "{", "request", ".", "patch", "(", "{", "url", ":", "host", "+", "'databases/'", "+", "db", "+", "'/docs/'", "+", "id", ",", "headers", ":", "{", "'Content-Type'", ":", "'application/json; charset=utf-8'", "}", ",", "body", ":", "JSON", ".", "stringify", "(", "operations", ")", "}", ",", "function", "(", "error", ",", "response", ",", "resBody", ")", "{", "if", "(", "!", "error", "&&", "response", ".", "statusCode", "===", "200", ")", "{", "var", "result", "=", "JSON", ".", "parse", "(", "resBody", ")", ";", "cb", "(", "null", ",", "result", ")", ";", "}", "else", "{", "cb", "(", "error", "||", "new", "Error", "(", "response", ".", "statusCode", ")", ",", "null", ")", ";", "}", "}", ")", ";", "}" ]
Applies patch operations to document with given id. @param {string} db @param {string} id @param {Array<Object>} operations @param {Function} cb
[ "Applies", "patch", "operations", "to", "document", "with", "given", "id", "." ]
62353a62f634be90f7aa4c36f19574ecd720b463
https://github.com/VasoBolkvadze/noderaven/blob/62353a62f634be90f7aa4c36f19574ecd720b463/index.js#L318-L333
57,604
VasoBolkvadze/noderaven
index.js
function (db, entityName, doc, cb) { request.post({ url: host + 'databases/' + db + '/docs', headers: { 'Content-Type': 'application/json; charset=utf-8', 'Raven-Entity-Name': entityName }, body: JSON.stringify(doc) }, function (error, response, resBody) { if (!error && (response.statusCode === 201 || response.statusCode === 200)) { var result = JSON.parse(resBody); cb(null, result); } else { cb(error || new Error(response.statusCode), null); } }); }
javascript
function (db, entityName, doc, cb) { request.post({ url: host + 'databases/' + db + '/docs', headers: { 'Content-Type': 'application/json; charset=utf-8', 'Raven-Entity-Name': entityName }, body: JSON.stringify(doc) }, function (error, response, resBody) { if (!error && (response.statusCode === 201 || response.statusCode === 200)) { var result = JSON.parse(resBody); cb(null, result); } else { cb(error || new Error(response.statusCode), null); } }); }
[ "function", "(", "db", ",", "entityName", ",", "doc", ",", "cb", ")", "{", "request", ".", "post", "(", "{", "url", ":", "host", "+", "'databases/'", "+", "db", "+", "'/docs'", ",", "headers", ":", "{", "'Content-Type'", ":", "'application/json; charset=utf-8'", ",", "'Raven-Entity-Name'", ":", "entityName", "}", ",", "body", ":", "JSON", ".", "stringify", "(", "doc", ")", "}", ",", "function", "(", "error", ",", "response", ",", "resBody", ")", "{", "if", "(", "!", "error", "&&", "(", "response", ".", "statusCode", "===", "201", "||", "response", ".", "statusCode", "===", "200", ")", ")", "{", "var", "result", "=", "JSON", ".", "parse", "(", "resBody", ")", ";", "cb", "(", "null", ",", "result", ")", ";", "}", "else", "{", "cb", "(", "error", "||", "new", "Error", "(", "response", ".", "statusCode", ")", ",", "null", ")", ";", "}", "}", ")", ";", "}" ]
Stores given document, returns raven generated id in callback. @param {string} db @param {string} entityName @param {Object} doc @param {Function} cb
[ "Stores", "given", "document", "returns", "raven", "generated", "id", "in", "callback", "." ]
62353a62f634be90f7aa4c36f19574ecd720b463
https://github.com/VasoBolkvadze/noderaven/blob/62353a62f634be90f7aa4c36f19574ecd720b463/index.js#L340-L356
57,605
jfseb/mgnlq_er
js/match/inputFilter.js
reinforceDistWeight
function reinforceDistWeight(dist, category) { var abs = Math.abs(dist); return 1.0 + (Algol.aReinforceDistWeight[abs] || 0); }
javascript
function reinforceDistWeight(dist, category) { var abs = Math.abs(dist); return 1.0 + (Algol.aReinforceDistWeight[abs] || 0); }
[ "function", "reinforceDistWeight", "(", "dist", ",", "category", ")", "{", "var", "abs", "=", "Math", ".", "abs", "(", "dist", ")", ";", "return", "1.0", "+", "(", "Algol", ".", "aReinforceDistWeight", "[", "abs", "]", "||", "0", ")", ";", "}" ]
Calculate a weight factor for a given distance and category @param {integer} dist distance in words @param {string} category category to use @returns {number} a distance factor >= 1 1.0 for no effect
[ "Calculate", "a", "weight", "factor", "for", "a", "given", "distance", "and", "category" ]
2fbfb65aabab39f7708d09e98b3e2618a7ebac30
https://github.com/jfseb/mgnlq_er/blob/2fbfb65aabab39f7708d09e98b3e2618a7ebac30/js/match/inputFilter.js#L963-L966
57,606
jfseb/mgnlq_er
js/match/inputFilter.js
extractCategoryMap
function extractCategoryMap(oSentence) { var res = {}; debuglog(debuglog.enabled ? ('extractCategoryMap ' + JSON.stringify(oSentence)) : '-'); oSentence.forEach(function (oWord, iIndex) { if (oWord.category === IFMatch.CAT_CATEGORY) { res[oWord.matchedString] = res[oWord.matchedString] || []; res[oWord.matchedString].push({ pos: iIndex }); } }); utils.deepFreeze(res); return res; }
javascript
function extractCategoryMap(oSentence) { var res = {}; debuglog(debuglog.enabled ? ('extractCategoryMap ' + JSON.stringify(oSentence)) : '-'); oSentence.forEach(function (oWord, iIndex) { if (oWord.category === IFMatch.CAT_CATEGORY) { res[oWord.matchedString] = res[oWord.matchedString] || []; res[oWord.matchedString].push({ pos: iIndex }); } }); utils.deepFreeze(res); return res; }
[ "function", "extractCategoryMap", "(", "oSentence", ")", "{", "var", "res", "=", "{", "}", ";", "debuglog", "(", "debuglog", ".", "enabled", "?", "(", "'extractCategoryMap '", "+", "JSON", ".", "stringify", "(", "oSentence", ")", ")", ":", "'-'", ")", ";", "oSentence", ".", "forEach", "(", "function", "(", "oWord", ",", "iIndex", ")", "{", "if", "(", "oWord", ".", "category", "===", "IFMatch", ".", "CAT_CATEGORY", ")", "{", "res", "[", "oWord", ".", "matchedString", "]", "=", "res", "[", "oWord", ".", "matchedString", "]", "||", "[", "]", ";", "res", "[", "oWord", ".", "matchedString", "]", ".", "push", "(", "{", "pos", ":", "iIndex", "}", ")", ";", "}", "}", ")", ";", "utils", ".", "deepFreeze", "(", "res", ")", ";", "return", "res", ";", "}" ]
Given a sentence, extact categories
[ "Given", "a", "sentence", "extact", "categories" ]
2fbfb65aabab39f7708d09e98b3e2618a7ebac30
https://github.com/jfseb/mgnlq_er/blob/2fbfb65aabab39f7708d09e98b3e2618a7ebac30/js/match/inputFilter.js#L971-L982
57,607
constantology/id8
id8.js
alias
function alias( name_current, name_alias ) { if ( util.type( this ) != desc_class_type.value ) return null; var name, proto = this.prototype; if ( is_obj( name_current ) ) { for ( name in name_current ) !util.has( name_current, name ) || alias.call( this, name, name_current[name] ); } else if ( typeof proto[name_current] == 'function' ) util.def( proto, name_alias, get_method_descriptor( proto, name_current ), true ); return this; }
javascript
function alias( name_current, name_alias ) { if ( util.type( this ) != desc_class_type.value ) return null; var name, proto = this.prototype; if ( is_obj( name_current ) ) { for ( name in name_current ) !util.has( name_current, name ) || alias.call( this, name, name_current[name] ); } else if ( typeof proto[name_current] == 'function' ) util.def( proto, name_alias, get_method_descriptor( proto, name_current ), true ); return this; }
[ "function", "alias", "(", "name_current", ",", "name_alias", ")", "{", "if", "(", "util", ".", "type", "(", "this", ")", "!=", "desc_class_type", ".", "value", ")", "return", "null", ";", "var", "name", ",", "proto", "=", "this", ".", "prototype", ";", "if", "(", "is_obj", "(", "name_current", ")", ")", "{", "for", "(", "name", "in", "name_current", ")", "!", "util", ".", "has", "(", "name_current", ",", "name", ")", "||", "alias", ".", "call", "(", "this", ",", "name", ",", "name_current", "[", "name", "]", ")", ";", "}", "else", "if", "(", "typeof", "proto", "[", "name_current", "]", "==", "'function'", ")", "util", ".", "def", "(", "proto", ",", "name_alias", ",", "get_method_descriptor", "(", "proto", ",", "name_current", ")", ",", "true", ")", ";", "return", "this", ";", "}" ]
Class static methods
[ "Class", "static", "methods" ]
8e97cbf56406da2cd53f825fa4f24ae2263971ce
https://github.com/constantology/id8/blob/8e97cbf56406da2cd53f825fa4f24ae2263971ce/id8.js#L232-L246
57,608
constantology/id8
id8.js
get_args
function get_args( args, fn_curr, fn_prev ) { if ( args.length && OP.toString.call( args[0] ) === '[object Arguments]' ) { if ( args.length < 2 && arguments.length > 1 ) { if ( fn_curr in internal_method_names ) return get_args( args[0] ); if ( fn_prev && fn_curr === fn_prev ) return args[0]; } } return args; }
javascript
function get_args( args, fn_curr, fn_prev ) { if ( args.length && OP.toString.call( args[0] ) === '[object Arguments]' ) { if ( args.length < 2 && arguments.length > 1 ) { if ( fn_curr in internal_method_names ) return get_args( args[0] ); if ( fn_prev && fn_curr === fn_prev ) return args[0]; } } return args; }
[ "function", "get_args", "(", "args", ",", "fn_curr", ",", "fn_prev", ")", "{", "if", "(", "args", ".", "length", "&&", "OP", ".", "toString", ".", "call", "(", "args", "[", "0", "]", ")", "===", "'[object Arguments]'", ")", "{", "if", "(", "args", ".", "length", "<", "2", "&&", "arguments", ".", "length", ">", "1", ")", "{", "if", "(", "fn_curr", "in", "internal_method_names", ")", "return", "get_args", "(", "args", "[", "0", "]", ")", ";", "if", "(", "fn_prev", "&&", "fn_curr", "===", "fn_prev", ")", "return", "args", "[", "0", "]", ";", "}", "}", "return", "args", ";", "}" ]
Class instance method helpers
[ "Class", "instance", "method", "helpers" ]
8e97cbf56406da2cd53f825fa4f24ae2263971ce
https://github.com/constantology/id8/blob/8e97cbf56406da2cd53f825fa4f24ae2263971ce/id8.js#L277-L287
57,609
constantology/id8
id8.js
add
function add( key, value ) { var desc; switch ( typeof value ) { case 'object' : desc = util.type( value ) == 'descriptor' ? value : util.describe( { value : value }, 'cw' ); break; case 'function' : desc = util.describe( make_method( 'parent', value, get_method_descriptor( this, key ), key ), 'cw' ); break; default : desc = util.describe( value, 'cew' ); } util.def( this, key, desc, true ); return this.constructor; }
javascript
function add( key, value ) { var desc; switch ( typeof value ) { case 'object' : desc = util.type( value ) == 'descriptor' ? value : util.describe( { value : value }, 'cw' ); break; case 'function' : desc = util.describe( make_method( 'parent', value, get_method_descriptor( this, key ), key ), 'cw' ); break; default : desc = util.describe( value, 'cew' ); } util.def( this, key, desc, true ); return this.constructor; }
[ "function", "add", "(", "key", ",", "value", ")", "{", "var", "desc", ";", "switch", "(", "typeof", "value", ")", "{", "case", "'object'", ":", "desc", "=", "util", ".", "type", "(", "value", ")", "==", "'descriptor'", "?", "value", ":", "util", ".", "describe", "(", "{", "value", ":", "value", "}", ",", "'cw'", ")", ";", "break", ";", "case", "'function'", ":", "desc", "=", "util", ".", "describe", "(", "make_method", "(", "'parent'", ",", "value", ",", "get_method_descriptor", "(", "this", ",", "key", ")", ",", "key", ")", ",", "'cw'", ")", ";", "break", ";", "default", ":", "desc", "=", "util", ".", "describe", "(", "value", ",", "'cew'", ")", ";", "}", "util", ".", "def", "(", "this", ",", "key", ",", "desc", ",", "true", ")", ";", "return", "this", ".", "constructor", ";", "}" ]
Class construction methods
[ "Class", "construction", "methods" ]
8e97cbf56406da2cd53f825fa4f24ae2263971ce
https://github.com/constantology/id8/blob/8e97cbf56406da2cd53f825fa4f24ae2263971ce/id8.js#L304-L313
57,610
crispy1989/crisphooks
crisphooks.js
CrispHooks
function CrispHooks(options) { if (options && options.eventEmitter) { this.on = CrispHooks.prototype.hookSync; this.emit = CrispHooks.prototype.triggerSync; } this._hooks = {}; }
javascript
function CrispHooks(options) { if (options && options.eventEmitter) { this.on = CrispHooks.prototype.hookSync; this.emit = CrispHooks.prototype.triggerSync; } this._hooks = {}; }
[ "function", "CrispHooks", "(", "options", ")", "{", "if", "(", "options", "&&", "options", ".", "eventEmitter", ")", "{", "this", ".", "on", "=", "CrispHooks", ".", "prototype", ".", "hookSync", ";", "this", ".", "emit", "=", "CrispHooks", ".", "prototype", ".", "triggerSync", ";", "}", "this", ".", "_hooks", "=", "{", "}", ";", "}" ]
Main CrispHooks constructor. This creates an object to which hooks can be added, and on which hooks can be called. @class CrispHooks @constructor @param {Object} options - Options changing the behavior of the hooks object @param {Boolean} options.eventEmitter - Add EventEmitter-style aliases
[ "Main", "CrispHooks", "constructor", ".", "This", "creates", "an", "object", "to", "which", "hooks", "can", "be", "added", "and", "on", "which", "hooks", "can", "be", "called", "." ]
6251a5a0b650086ec7207d17dca623581f7f5d66
https://github.com/crispy1989/crisphooks/blob/6251a5a0b650086ec7207d17dca623581f7f5d66/crisphooks.js#L12-L18
57,611
chrisJohn404/ljswitchboard-modbus_map
lib/json_constants_parser.js
function(options) { var constantsData = options.constantsData; var location = options.location; var index = options.index; var name = options.name; var bufferInfo; var addData = false; // Search for a buffer's info array_registers.forEach(function(arrayRegister) { if(name === arrayRegister.data) { bufferInfo = { 'size': arrayRegister.size, }; var importTypeData = true; if(arrayRegister.type) { if(arrayRegister.type !== 'raw') { bufferInfo.type = arrayRegister.type; importTypeData = false; } } if(importTypeData) { bufferInfo.type = constantsData[location][index].type; } addData = true; } }); if(addData) { constantsData[location][index].bufferInfo = bufferInfo; } }
javascript
function(options) { var constantsData = options.constantsData; var location = options.location; var index = options.index; var name = options.name; var bufferInfo; var addData = false; // Search for a buffer's info array_registers.forEach(function(arrayRegister) { if(name === arrayRegister.data) { bufferInfo = { 'size': arrayRegister.size, }; var importTypeData = true; if(arrayRegister.type) { if(arrayRegister.type !== 'raw') { bufferInfo.type = arrayRegister.type; importTypeData = false; } } if(importTypeData) { bufferInfo.type = constantsData[location][index].type; } addData = true; } }); if(addData) { constantsData[location][index].bufferInfo = bufferInfo; } }
[ "function", "(", "options", ")", "{", "var", "constantsData", "=", "options", ".", "constantsData", ";", "var", "location", "=", "options", ".", "location", ";", "var", "index", "=", "options", ".", "index", ";", "var", "name", "=", "options", ".", "name", ";", "var", "bufferInfo", ";", "var", "addData", "=", "false", ";", "// Search for a buffer's info", "array_registers", ".", "forEach", "(", "function", "(", "arrayRegister", ")", "{", "if", "(", "name", "===", "arrayRegister", ".", "data", ")", "{", "bufferInfo", "=", "{", "'size'", ":", "arrayRegister", ".", "size", ",", "}", ";", "var", "importTypeData", "=", "true", ";", "if", "(", "arrayRegister", ".", "type", ")", "{", "if", "(", "arrayRegister", ".", "type", "!==", "'raw'", ")", "{", "bufferInfo", ".", "type", "=", "arrayRegister", ".", "type", ";", "importTypeData", "=", "false", ";", "}", "}", "if", "(", "importTypeData", ")", "{", "bufferInfo", ".", "type", "=", "constantsData", "[", "location", "]", "[", "index", "]", ".", "type", ";", "}", "addData", "=", "true", ";", "}", "}", ")", ";", "if", "(", "addData", ")", "{", "constantsData", "[", "location", "]", "[", "index", "]", ".", "bufferInfo", "=", "bufferInfo", ";", "}", "}" ]
This function forces the creation of the bufferInfo attribute to registers that contains more information about them.
[ "This", "function", "forces", "the", "creation", "of", "the", "bufferInfo", "attribute", "to", "registers", "that", "contains", "more", "information", "about", "them", "." ]
886e32778e854bc3d2a0170d3c27e1bb3adf200d
https://github.com/chrisJohn404/ljswitchboard-modbus_map/blob/886e32778e854bc3d2a0170d3c27e1bb3adf200d/lib/json_constants_parser.js#L237-L269
57,612
chrisJohn404/ljswitchboard-modbus_map
lib/json_constants_parser.js
function(constantsData) { var i; var registerName; try { for(i = 0; i < constantsData.registers.length; i++) { registerName = constantsData.registers[i].name; if(buffer_registers.indexOf(registerName) >= 0) { constantsData.registers[i].isBuffer = true; addMissingBufferRegisterInfoObject({ 'constantsData': constantsData, 'location': 'registers', 'index': i, 'name': registerName, }); } } for(i = 0; i < constantsData.registers_beta.length; i++) { registerName = constantsData.registers_beta[i].name; if(buffer_registers.indexOf(registerName) >= 0) { constantsData.registers_beta[i].isBuffer = true; addMissingBufferRegisterInfoObject({ 'constantsData': constantsData, 'location': 'registers_beta', 'index': i, 'name': registerName, }); } } } catch(err) { console.log('Error adding missing buffer register flags', err, i); } return constantsData; }
javascript
function(constantsData) { var i; var registerName; try { for(i = 0; i < constantsData.registers.length; i++) { registerName = constantsData.registers[i].name; if(buffer_registers.indexOf(registerName) >= 0) { constantsData.registers[i].isBuffer = true; addMissingBufferRegisterInfoObject({ 'constantsData': constantsData, 'location': 'registers', 'index': i, 'name': registerName, }); } } for(i = 0; i < constantsData.registers_beta.length; i++) { registerName = constantsData.registers_beta[i].name; if(buffer_registers.indexOf(registerName) >= 0) { constantsData.registers_beta[i].isBuffer = true; addMissingBufferRegisterInfoObject({ 'constantsData': constantsData, 'location': 'registers_beta', 'index': i, 'name': registerName, }); } } } catch(err) { console.log('Error adding missing buffer register flags', err, i); } return constantsData; }
[ "function", "(", "constantsData", ")", "{", "var", "i", ";", "var", "registerName", ";", "try", "{", "for", "(", "i", "=", "0", ";", "i", "<", "constantsData", ".", "registers", ".", "length", ";", "i", "++", ")", "{", "registerName", "=", "constantsData", ".", "registers", "[", "i", "]", ".", "name", ";", "if", "(", "buffer_registers", ".", "indexOf", "(", "registerName", ")", ">=", "0", ")", "{", "constantsData", ".", "registers", "[", "i", "]", ".", "isBuffer", "=", "true", ";", "addMissingBufferRegisterInfoObject", "(", "{", "'constantsData'", ":", "constantsData", ",", "'location'", ":", "'registers'", ",", "'index'", ":", "i", ",", "'name'", ":", "registerName", ",", "}", ")", ";", "}", "}", "for", "(", "i", "=", "0", ";", "i", "<", "constantsData", ".", "registers_beta", ".", "length", ";", "i", "++", ")", "{", "registerName", "=", "constantsData", ".", "registers_beta", "[", "i", "]", ".", "name", ";", "if", "(", "buffer_registers", ".", "indexOf", "(", "registerName", ")", ">=", "0", ")", "{", "constantsData", ".", "registers_beta", "[", "i", "]", ".", "isBuffer", "=", "true", ";", "addMissingBufferRegisterInfoObject", "(", "{", "'constantsData'", ":", "constantsData", ",", "'location'", ":", "'registers_beta'", ",", "'index'", ":", "i", ",", "'name'", ":", "registerName", ",", "}", ")", ";", "}", "}", "}", "catch", "(", "err", ")", "{", "console", ".", "log", "(", "'Error adding missing buffer register flags'", ",", "err", ",", "i", ")", ";", "}", "return", "constantsData", ";", "}" ]
This function forces the isBuffer register flag to be set for known buffer registers.
[ "This", "function", "forces", "the", "isBuffer", "register", "flag", "to", "be", "set", "for", "known", "buffer", "registers", "." ]
886e32778e854bc3d2a0170d3c27e1bb3adf200d
https://github.com/chrisJohn404/ljswitchboard-modbus_map/blob/886e32778e854bc3d2a0170d3c27e1bb3adf200d/lib/json_constants_parser.js#L274-L308
57,613
maenuLabs/ch.maenulabs.validation
ch.maenulabs.validation.js
function (checks) { checks = checks || []; this.checks = []; for (var i = 0; i < checks.length; i = i + 1) { this.add(checks[i]); } }
javascript
function (checks) { checks = checks || []; this.checks = []; for (var i = 0; i < checks.length; i = i + 1) { this.add(checks[i]); } }
[ "function", "(", "checks", ")", "{", "checks", "=", "checks", "||", "[", "]", ";", "this", ".", "checks", "=", "[", "]", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "checks", ".", "length", ";", "i", "=", "i", "+", "1", ")", "{", "this", ".", "add", "(", "checks", "[", "i", "]", ")", ";", "}", "}" ]
The checks to perform. @protected @property checks @type Array Creates a Validation. @constructor @param Array [checks=[]] The Checks to add
[ "The", "checks", "to", "perform", "." ]
92fd70edf5aa69aa46757c1b1c7d107b8a7ede08
https://github.com/maenuLabs/ch.maenulabs.validation/blob/92fd70edf5aa69aa46757c1b1c7d107b8a7ede08/ch.maenulabs.validation.js#L43-L49
57,614
maenuLabs/ch.maenulabs.validation
ch.maenulabs.validation.js
function (object) { var values = []; for (var i = 0; i < this.properties.length; i = i + 1) { if (object == null) { values.push(undefined); } else { values.push(object[this.properties[i]]); } } return values; }
javascript
function (object) { var values = []; for (var i = 0; i < this.properties.length; i = i + 1) { if (object == null) { values.push(undefined); } else { values.push(object[this.properties[i]]); } } return values; }
[ "function", "(", "object", ")", "{", "var", "values", "=", "[", "]", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "this", ".", "properties", ".", "length", ";", "i", "=", "i", "+", "1", ")", "{", "if", "(", "object", "==", "null", ")", "{", "values", ".", "push", "(", "undefined", ")", ";", "}", "else", "{", "values", ".", "push", "(", "object", "[", "this", ".", "properties", "[", "i", "]", "]", ")", ";", "}", "}", "return", "values", ";", "}" ]
Gets the values of the properties to check. @protected @method getValues @param * object The object to inspect @return Array The values of the properties in the same order
[ "Gets", "the", "values", "of", "the", "properties", "to", "check", "." ]
92fd70edf5aa69aa46757c1b1c7d107b8a7ede08
https://github.com/maenuLabs/ch.maenulabs.validation/blob/92fd70edf5aa69aa46757c1b1c7d107b8a7ede08/ch.maenulabs.validation.js#L190-L200
57,615
maenuLabs/ch.maenulabs.validation
ch.maenulabs.validation.js
function (property, validation, required) { if (required == null) { required = true; } this.property = property; this.validation = validation; this.required = required; }
javascript
function (property, validation, required) { if (required == null) { required = true; } this.property = property; this.validation = validation; this.required = required; }
[ "function", "(", "property", ",", "validation", ",", "required", ")", "{", "if", "(", "required", "==", "null", ")", "{", "required", "=", "true", ";", "}", "this", ".", "property", "=", "property", ";", "this", ".", "validation", "=", "validation", ";", "this", ".", "required", "=", "required", ";", "}" ]
The property name. @private @property property @type String The validation to perform on property. @private @property validation @type Validation Creates an ObjectCheck. @constructor @param String property The property name @param Validation validation The validation to perform on property @param Boolean [required=true] Whether or not the validation is performed if the property is undefined
[ "The", "property", "name", "." ]
92fd70edf5aa69aa46757c1b1c7d107b8a7ede08
https://github.com/maenuLabs/ch.maenulabs.validation/blob/92fd70edf5aa69aa46757c1b1c7d107b8a7ede08/ch.maenulabs.validation.js#L237-L244
57,616
maenuLabs/ch.maenulabs.validation
ch.maenulabs.validation.js
function (property, messager) { this.base('initialize')([property], function (value) { return value != null; }, messager || function () { return i18n['ch/maenulabs/validation/ExistenceCheck'].message(); }); }
javascript
function (property, messager) { this.base('initialize')([property], function (value) { return value != null; }, messager || function () { return i18n['ch/maenulabs/validation/ExistenceCheck'].message(); }); }
[ "function", "(", "property", ",", "messager", ")", "{", "this", ".", "base", "(", "'initialize'", ")", "(", "[", "property", "]", ",", "function", "(", "value", ")", "{", "return", "value", "!=", "null", ";", "}", ",", "messager", "||", "function", "(", ")", "{", "return", "i18n", "[", "'ch/maenulabs/validation/ExistenceCheck'", "]", ".", "message", "(", ")", ";", "}", ")", ";", "}" ]
Creates an ExistenceCheck. @constructor @param String property The property name @param Function [messager] The messager
[ "Creates", "an", "ExistenceCheck", "." ]
92fd70edf5aa69aa46757c1b1c7d107b8a7ede08
https://github.com/maenuLabs/ch.maenulabs.validation/blob/92fd70edf5aa69aa46757c1b1c7d107b8a7ede08/ch.maenulabs.validation.js#L290-L296
57,617
maenuLabs/ch.maenulabs.validation
ch.maenulabs.validation.js
function (property, limit, messager) { this.base('initialize')([property], function (value) { return value > limit; }, messager || function () { return i18n['ch/maenulabs/validation/GreaterThanCheck'].message({ amount: limit }); }); }
javascript
function (property, limit, messager) { this.base('initialize')([property], function (value) { return value > limit; }, messager || function () { return i18n['ch/maenulabs/validation/GreaterThanCheck'].message({ amount: limit }); }); }
[ "function", "(", "property", ",", "limit", ",", "messager", ")", "{", "this", ".", "base", "(", "'initialize'", ")", "(", "[", "property", "]", ",", "function", "(", "value", ")", "{", "return", "value", ">", "limit", ";", "}", ",", "messager", "||", "function", "(", ")", "{", "return", "i18n", "[", "'ch/maenulabs/validation/GreaterThanCheck'", "]", ".", "message", "(", "{", "amount", ":", "limit", "}", ")", ";", "}", ")", ";", "}" ]
Creates an GreaterThanCheck. @constructor @param String property The property name @param Number limit The value must be at least this limit @param Function [messager] The messager
[ "Creates", "an", "GreaterThanCheck", "." ]
92fd70edf5aa69aa46757c1b1c7d107b8a7ede08
https://github.com/maenuLabs/ch.maenulabs.validation/blob/92fd70edf5aa69aa46757c1b1c7d107b8a7ede08/ch.maenulabs.validation.js#L378-L386
57,618
maenuLabs/ch.maenulabs.validation
ch.maenulabs.validation.js
function (property, minimum, maximum, required) { this.base('initialize')(property, new Validation([ new AtLeastCheck('length', minimum, function () { return i18n['ch/maenulabs/validation/StringLengthRangeCheck'].minimum({ amount: minimum }); }), new AtMostCheck('length', maximum, function () { return i18n['ch/maenulabs/validation/StringLengthRangeCheck'].maximum({ amount: maximum }); }) ]), required); }
javascript
function (property, minimum, maximum, required) { this.base('initialize')(property, new Validation([ new AtLeastCheck('length', minimum, function () { return i18n['ch/maenulabs/validation/StringLengthRangeCheck'].minimum({ amount: minimum }); }), new AtMostCheck('length', maximum, function () { return i18n['ch/maenulabs/validation/StringLengthRangeCheck'].maximum({ amount: maximum }); }) ]), required); }
[ "function", "(", "property", ",", "minimum", ",", "maximum", ",", "required", ")", "{", "this", ".", "base", "(", "'initialize'", ")", "(", "property", ",", "new", "Validation", "(", "[", "new", "AtLeastCheck", "(", "'length'", ",", "minimum", ",", "function", "(", ")", "{", "return", "i18n", "[", "'ch/maenulabs/validation/StringLengthRangeCheck'", "]", ".", "minimum", "(", "{", "amount", ":", "minimum", "}", ")", ";", "}", ")", ",", "new", "AtMostCheck", "(", "'length'", ",", "maximum", ",", "function", "(", ")", "{", "return", "i18n", "[", "'ch/maenulabs/validation/StringLengthRangeCheck'", "]", ".", "maximum", "(", "{", "amount", ":", "maximum", "}", ")", ";", "}", ")", "]", ")", ",", "required", ")", ";", "}" ]
Creates an StringLengthRangeCheck. @constructor @param String property The property name @param Number minimum The minimum length @param Number maximum The maximum length @param Boolean [required=true] Whether or not the validation is performed if the property is undefined
[ "Creates", "an", "StringLengthRangeCheck", "." ]
92fd70edf5aa69aa46757c1b1c7d107b8a7ede08
https://github.com/maenuLabs/ch.maenulabs.validation/blob/92fd70edf5aa69aa46757c1b1c7d107b8a7ede08/ch.maenulabs.validation.js#L443-L456
57,619
byu-oit/fully-typed
bin/typed.js
Typed
function Typed (config) { const typed = this; const hasDefault = config.hasOwnProperty('default'); // enum if (config.hasOwnProperty('enum')) { if (!Array.isArray(config.enum) || config.enum.length === 0) { throw Error(util.propertyErrorMessage('enum', config.enum, 'Expected a non-empty array')); } const copy = []; config.enum.forEach(function(v) { if (copy.indexOf(v) === -1) copy.push(v); }); config.enum = copy; } // transform if (config.transform && typeof config.transform !== 'function') { throw Error(util.propertyErrorMessage('transform', config.transform, 'Expected a function')); } // validate if (config.validator && typeof config.validator !== 'function') { throw Error(util.propertyErrorMessage('validator', config.validator, 'Expected a function')); } // define properties Object.defineProperties(typed, { default: { /** * @property * @name Typed#default * @type {function,*} */ value: config.default, writable: false }, enum: { /** * @property * @name Typed#enum * @readonly * @type {function,*} */ value: config.enum, writable: false }, hasDefault: { /** * @property * @name Typed#hasDefault * @type {boolean} */ value: hasDefault, writable: false }, transform: { /** * @property * @name Typed#transform * @readonly * @type {function} */ value: config.transform, writable: false }, type: { /** * @property * @name Typed#type * @readonly * @type {string,function} */ value: config.type, writable: false }, validator: { /** * @property * @name Typed#validator * @readonly * @type {function} */ value: config.validator, writable: false } }); return typed; }
javascript
function Typed (config) { const typed = this; const hasDefault = config.hasOwnProperty('default'); // enum if (config.hasOwnProperty('enum')) { if (!Array.isArray(config.enum) || config.enum.length === 0) { throw Error(util.propertyErrorMessage('enum', config.enum, 'Expected a non-empty array')); } const copy = []; config.enum.forEach(function(v) { if (copy.indexOf(v) === -1) copy.push(v); }); config.enum = copy; } // transform if (config.transform && typeof config.transform !== 'function') { throw Error(util.propertyErrorMessage('transform', config.transform, 'Expected a function')); } // validate if (config.validator && typeof config.validator !== 'function') { throw Error(util.propertyErrorMessage('validator', config.validator, 'Expected a function')); } // define properties Object.defineProperties(typed, { default: { /** * @property * @name Typed#default * @type {function,*} */ value: config.default, writable: false }, enum: { /** * @property * @name Typed#enum * @readonly * @type {function,*} */ value: config.enum, writable: false }, hasDefault: { /** * @property * @name Typed#hasDefault * @type {boolean} */ value: hasDefault, writable: false }, transform: { /** * @property * @name Typed#transform * @readonly * @type {function} */ value: config.transform, writable: false }, type: { /** * @property * @name Typed#type * @readonly * @type {string,function} */ value: config.type, writable: false }, validator: { /** * @property * @name Typed#validator * @readonly * @type {function} */ value: config.validator, writable: false } }); return typed; }
[ "function", "Typed", "(", "config", ")", "{", "const", "typed", "=", "this", ";", "const", "hasDefault", "=", "config", ".", "hasOwnProperty", "(", "'default'", ")", ";", "// enum", "if", "(", "config", ".", "hasOwnProperty", "(", "'enum'", ")", ")", "{", "if", "(", "!", "Array", ".", "isArray", "(", "config", ".", "enum", ")", "||", "config", ".", "enum", ".", "length", "===", "0", ")", "{", "throw", "Error", "(", "util", ".", "propertyErrorMessage", "(", "'enum'", ",", "config", ".", "enum", ",", "'Expected a non-empty array'", ")", ")", ";", "}", "const", "copy", "=", "[", "]", ";", "config", ".", "enum", ".", "forEach", "(", "function", "(", "v", ")", "{", "if", "(", "copy", ".", "indexOf", "(", "v", ")", "===", "-", "1", ")", "copy", ".", "push", "(", "v", ")", ";", "}", ")", ";", "config", ".", "enum", "=", "copy", ";", "}", "// transform", "if", "(", "config", ".", "transform", "&&", "typeof", "config", ".", "transform", "!==", "'function'", ")", "{", "throw", "Error", "(", "util", ".", "propertyErrorMessage", "(", "'transform'", ",", "config", ".", "transform", ",", "'Expected a function'", ")", ")", ";", "}", "// validate", "if", "(", "config", ".", "validator", "&&", "typeof", "config", ".", "validator", "!==", "'function'", ")", "{", "throw", "Error", "(", "util", ".", "propertyErrorMessage", "(", "'validator'", ",", "config", ".", "validator", ",", "'Expected a function'", ")", ")", ";", "}", "// define properties", "Object", ".", "defineProperties", "(", "typed", ",", "{", "default", ":", "{", "/**\n * @property\n * @name Typed#default\n * @type {function,*}\n */", "value", ":", "config", ".", "default", ",", "writable", ":", "false", "}", ",", "enum", ":", "{", "/**\n * @property\n * @name Typed#enum\n * @readonly\n * @type {function,*}\n */", "value", ":", "config", ".", "enum", ",", "writable", ":", "false", "}", ",", "hasDefault", ":", "{", "/**\n * @property\n * @name Typed#hasDefault\n * @type {boolean}\n */", "value", ":", "hasDefault", ",", "writable", ":", "false", "}", ",", "transform", ":", "{", "/**\n * @property\n * @name Typed#transform\n * @readonly\n * @type {function}\n */", "value", ":", "config", ".", "transform", ",", "writable", ":", "false", "}", ",", "type", ":", "{", "/**\n * @property\n * @name Typed#type\n * @readonly\n * @type {string,function}\n */", "value", ":", "config", ".", "type", ",", "writable", ":", "false", "}", ",", "validator", ":", "{", "/**\n * @property\n * @name Typed#validator\n * @readonly\n * @type {function}\n */", "value", ":", "config", ".", "validator", ",", "writable", ":", "false", "}", "}", ")", ";", "return", "typed", ";", "}" ]
Create a Typed instance. @param {object} config @returns {Typed} @constructor
[ "Create", "a", "Typed", "instance", "." ]
ed6b3ed88ffc72990acffb765232eaaee261afef
https://github.com/byu-oit/fully-typed/blob/ed6b3ed88ffc72990acffb765232eaaee261afef/bin/typed.js#L29-L124
57,620
greggman/hft-sample-ui
src/hft/scripts/misc/mobilehacks.js
function() { // Also fix all fucked up sizing var elements = document.querySelectorAll(".fixheight"); for (var ii = 0; ii < elements.length; ++ii) { var element = elements[ii]; var parent = element.parentNode; if (parseInt(element.style.height) !== parent.clientHeight) { element.style.height = parent.clientHeight + "px"; } } }
javascript
function() { // Also fix all fucked up sizing var elements = document.querySelectorAll(".fixheight"); for (var ii = 0; ii < elements.length; ++ii) { var element = elements[ii]; var parent = element.parentNode; if (parseInt(element.style.height) !== parent.clientHeight) { element.style.height = parent.clientHeight + "px"; } } }
[ "function", "(", ")", "{", "// Also fix all fucked up sizing", "var", "elements", "=", "document", ".", "querySelectorAll", "(", "\".fixheight\"", ")", ";", "for", "(", "var", "ii", "=", "0", ";", "ii", "<", "elements", ".", "length", ";", "++", "ii", ")", "{", "var", "element", "=", "elements", "[", "ii", "]", ";", "var", "parent", "=", "element", ".", "parentNode", ";", "if", "(", "parseInt", "(", "element", ".", "style", ".", "height", ")", "!==", "parent", ".", "clientHeight", ")", "{", "element", ".", "style", ".", "height", "=", "parent", ".", "clientHeight", "+", "\"px\"", ";", "}", "}", "}" ]
resets the height of any element with CSS class "fixeight" by setting its hight to the cliehgtHeight of its parent The problem this is trying to solve is sometimes you have an element set to 100% but when the phone rotates the browser does not reset the size of the element even though it's parent has been resized. This will be called automatically when the phone rotates or the window is resized but I found I often needed to call it manually at the start of a controller @memberOf module:MobileHacks
[ "resets", "the", "height", "of", "any", "element", "with", "CSS", "class", "fixeight", "by", "setting", "its", "hight", "to", "the", "cliehgtHeight", "of", "its", "parent" ]
b9e20afd5183db73522bcfae48225c87e01f68c0
https://github.com/greggman/hft-sample-ui/blob/b9e20afd5183db73522bcfae48225c87e01f68c0/src/hft/scripts/misc/mobilehacks.js#L95-L105
57,621
greggman/hft-sample-ui
src/hft/scripts/misc/mobilehacks.js
function() { if (!document.body) { setTimeout(stopSliding, 4); } else { document.body.addEventListener('touchmove', function(e) { e.preventDefault(); }, false); } }
javascript
function() { if (!document.body) { setTimeout(stopSliding, 4); } else { document.body.addEventListener('touchmove', function(e) { e.preventDefault(); }, false); } }
[ "function", "(", ")", "{", "if", "(", "!", "document", ".", "body", ")", "{", "setTimeout", "(", "stopSliding", ",", "4", ")", ";", "}", "else", "{", "document", ".", "body", ".", "addEventListener", "(", "'touchmove'", ",", "function", "(", "e", ")", "{", "e", ".", "preventDefault", "(", ")", ";", "}", ",", "false", ")", ";", "}", "}" ]
Prevents the browser from sliding the page when the user slides their finger. At least on iOS.
[ "Prevents", "the", "browser", "from", "sliding", "the", "page", "when", "the", "user", "slides", "their", "finger", ".", "At", "least", "on", "iOS", "." ]
b9e20afd5183db73522bcfae48225c87e01f68c0
https://github.com/greggman/hft-sample-ui/blob/b9e20afd5183db73522bcfae48225c87e01f68c0/src/hft/scripts/misc/mobilehacks.js#L143-L151
57,622
greggman/hft-sample-ui
src/hft/scripts/misc/mobilehacks.js
function() { // Note: This code is for games that require a certain orientation // on phones only. I'm making the assuption that tablets don't need // this. // // The issue I ran into is I tried to show several people games // and they had their phone orientation locked to portrait. Having // to go unlock just to play the game was frustrating. So, for // controllers than require landscape just try to make the page // show up in landscape. They'll understand they need to turn the phone. // // If the orientation is unlocked they'll turn and the page will // switch to landscape. If the orientation is locked then turning // the phone will not switch to landscape NOR will we get an orientation // event. var everything = $("hft-everything"); var detectPortrait = function() { if (screen.width < screen.height) { everything.className = "hft-portrait-to-landscape"; everything.style.width = window.innerHeight + "px"; everything.style.height = window.innerWidth + "px"; var viewport = document.querySelector("meta[name=viewport]"); viewport.setAttribute('content', 'width=device-height, initial-scale=1.0, maximum-scale=1, user-scalable=no, minimal-ui'); } else { everything.className = ""; } }; detectPortrait(); window.addEventListener('resize', detectPortrait, false); }
javascript
function() { // Note: This code is for games that require a certain orientation // on phones only. I'm making the assuption that tablets don't need // this. // // The issue I ran into is I tried to show several people games // and they had their phone orientation locked to portrait. Having // to go unlock just to play the game was frustrating. So, for // controllers than require landscape just try to make the page // show up in landscape. They'll understand they need to turn the phone. // // If the orientation is unlocked they'll turn and the page will // switch to landscape. If the orientation is locked then turning // the phone will not switch to landscape NOR will we get an orientation // event. var everything = $("hft-everything"); var detectPortrait = function() { if (screen.width < screen.height) { everything.className = "hft-portrait-to-landscape"; everything.style.width = window.innerHeight + "px"; everything.style.height = window.innerWidth + "px"; var viewport = document.querySelector("meta[name=viewport]"); viewport.setAttribute('content', 'width=device-height, initial-scale=1.0, maximum-scale=1, user-scalable=no, minimal-ui'); } else { everything.className = ""; } }; detectPortrait(); window.addEventListener('resize', detectPortrait, false); }
[ "function", "(", ")", "{", "// Note: This code is for games that require a certain orientation", "// on phones only. I'm making the assuption that tablets don't need", "// this.", "//", "// The issue I ran into is I tried to show several people games", "// and they had their phone orientation locked to portrait. Having", "// to go unlock just to play the game was frustrating. So, for", "// controllers than require landscape just try to make the page", "// show up in landscape. They'll understand they need to turn the phone.", "//", "// If the orientation is unlocked they'll turn and the page will", "// switch to landscape. If the orientation is locked then turning", "// the phone will not switch to landscape NOR will we get an orientation", "// event.", "var", "everything", "=", "$", "(", "\"hft-everything\"", ")", ";", "var", "detectPortrait", "=", "function", "(", ")", "{", "if", "(", "screen", ".", "width", "<", "screen", ".", "height", ")", "{", "everything", ".", "className", "=", "\"hft-portrait-to-landscape\"", ";", "everything", ".", "style", ".", "width", "=", "window", ".", "innerHeight", "+", "\"px\"", ";", "everything", ".", "style", ".", "height", "=", "window", ".", "innerWidth", "+", "\"px\"", ";", "var", "viewport", "=", "document", ".", "querySelector", "(", "\"meta[name=viewport]\"", ")", ";", "viewport", ".", "setAttribute", "(", "'content'", ",", "'width=device-height, initial-scale=1.0, maximum-scale=1, user-scalable=no, minimal-ui'", ")", ";", "}", "else", "{", "everything", ".", "className", "=", "\"\"", ";", "}", "}", ";", "detectPortrait", "(", ")", ";", "window", ".", "addEventListener", "(", "'resize'", ",", "detectPortrait", ",", "false", ")", ";", "}" ]
This DOESN'T WORK! I'm leaving it here so I can revisit it. The issue is all kinds of things mess up. Events are not rotated, the page does strange things.
[ "This", "DOESN", "T", "WORK!", "I", "m", "leaving", "it", "here", "so", "I", "can", "revisit", "it", ".", "The", "issue", "is", "all", "kinds", "of", "things", "mess", "up", ".", "Events", "are", "not", "rotated", "the", "page", "does", "strange", "things", "." ]
b9e20afd5183db73522bcfae48225c87e01f68c0
https://github.com/greggman/hft-sample-ui/blob/b9e20afd5183db73522bcfae48225c87e01f68c0/src/hft/scripts/misc/mobilehacks.js#L158-L189
57,623
waka/node-bowl
lib/logger.js
createLogger
function createLogger(opt_level, opt_dir) { var config = getLogConfig(opt_level, opt_dir); var transports = getTransports(config); // check logdir if (!fs.existsSync(config.file.dir)) { throw new Error( util.format('The logdir does not exist: %s', config.file.dir)); } // create instance var logger = new (winston.Logger)({ transports: [ new winston.transports.Console(transports.console), new winston.transports.File(transports.file) ], exitOnError: false, exceptionHandlers: [ new winston.transports.File(transports.error) ] }); // use syslog's levels logger.setLevels(winston.config.syslog.levels); // if production env, remove console logger if (process.env.NODE_ENV === 'production') { logger.remove(winston.transports.Console); } return logger; }
javascript
function createLogger(opt_level, opt_dir) { var config = getLogConfig(opt_level, opt_dir); var transports = getTransports(config); // check logdir if (!fs.existsSync(config.file.dir)) { throw new Error( util.format('The logdir does not exist: %s', config.file.dir)); } // create instance var logger = new (winston.Logger)({ transports: [ new winston.transports.Console(transports.console), new winston.transports.File(transports.file) ], exitOnError: false, exceptionHandlers: [ new winston.transports.File(transports.error) ] }); // use syslog's levels logger.setLevels(winston.config.syslog.levels); // if production env, remove console logger if (process.env.NODE_ENV === 'production') { logger.remove(winston.transports.Console); } return logger; }
[ "function", "createLogger", "(", "opt_level", ",", "opt_dir", ")", "{", "var", "config", "=", "getLogConfig", "(", "opt_level", ",", "opt_dir", ")", ";", "var", "transports", "=", "getTransports", "(", "config", ")", ";", "// check logdir", "if", "(", "!", "fs", ".", "existsSync", "(", "config", ".", "file", ".", "dir", ")", ")", "{", "throw", "new", "Error", "(", "util", ".", "format", "(", "'The logdir does not exist: %s'", ",", "config", ".", "file", ".", "dir", ")", ")", ";", "}", "// create instance", "var", "logger", "=", "new", "(", "winston", ".", "Logger", ")", "(", "{", "transports", ":", "[", "new", "winston", ".", "transports", ".", "Console", "(", "transports", ".", "console", ")", ",", "new", "winston", ".", "transports", ".", "File", "(", "transports", ".", "file", ")", "]", ",", "exitOnError", ":", "false", ",", "exceptionHandlers", ":", "[", "new", "winston", ".", "transports", ".", "File", "(", "transports", ".", "error", ")", "]", "}", ")", ";", "// use syslog's levels", "logger", ".", "setLevels", "(", "winston", ".", "config", ".", "syslog", ".", "levels", ")", ";", "// if production env, remove console logger", "if", "(", "process", ".", "env", ".", "NODE_ENV", "===", "'production'", ")", "{", "logger", ".", "remove", "(", "winston", ".", "transports", ".", "Console", ")", ";", "}", "return", "logger", ";", "}" ]
Instantiate winston logger. @param {string=} opt_level . @param {string=} opt_dir . @return {winston.Logger} .
[ "Instantiate", "winston", "logger", "." ]
671e8b16371a279e23b65bb9b2ff9dae047b6644
https://github.com/waka/node-bowl/blob/671e8b16371a279e23b65bb9b2ff9dae047b6644/lib/logger.js#L65-L96
57,624
waka/node-bowl
lib/logger.js
getLogConfig
function getLogConfig(opt_level, opt_dir) { var config = _.clone(defaultConfig); if (opt_level) { config.level = opt_level; } if (opt_dir) { config.file.dir = opt_dir; } return config; }
javascript
function getLogConfig(opt_level, opt_dir) { var config = _.clone(defaultConfig); if (opt_level) { config.level = opt_level; } if (opt_dir) { config.file.dir = opt_dir; } return config; }
[ "function", "getLogConfig", "(", "opt_level", ",", "opt_dir", ")", "{", "var", "config", "=", "_", ".", "clone", "(", "defaultConfig", ")", ";", "if", "(", "opt_level", ")", "{", "config", ".", "level", "=", "opt_level", ";", "}", "if", "(", "opt_dir", ")", "{", "config", ".", "file", ".", "dir", "=", "opt_dir", ";", "}", "return", "config", ";", "}" ]
Merge user's configurations. @param {string=} opt_level . @param {string=} opt_dir . @return {Object} .
[ "Merge", "user", "s", "configurations", "." ]
671e8b16371a279e23b65bb9b2ff9dae047b6644
https://github.com/waka/node-bowl/blob/671e8b16371a279e23b65bb9b2ff9dae047b6644/lib/logger.js#L106-L115
57,625
waka/node-bowl
lib/logger.js
getTransports
function getTransports(config) { var transports = { console: { level: config.level, handleExceptions: true, colorize: true, prettyPrint: true }, file: { level: config.level, filename: path.join(config.file.dir, FILE_NAME), maxsize: config.file.maxsize, maxFiles: config.file.maxfiles, json: false, timestamp: true } }; transports.error = { filename: path.join(config.file.dir, ERROR_FILE_NAME), maxsize: config.file.maxsize, maxFiles: config.file.maxfiles, timestamp: true, json: true, prettyPrint: true }; return transports; }
javascript
function getTransports(config) { var transports = { console: { level: config.level, handleExceptions: true, colorize: true, prettyPrint: true }, file: { level: config.level, filename: path.join(config.file.dir, FILE_NAME), maxsize: config.file.maxsize, maxFiles: config.file.maxfiles, json: false, timestamp: true } }; transports.error = { filename: path.join(config.file.dir, ERROR_FILE_NAME), maxsize: config.file.maxsize, maxFiles: config.file.maxfiles, timestamp: true, json: true, prettyPrint: true }; return transports; }
[ "function", "getTransports", "(", "config", ")", "{", "var", "transports", "=", "{", "console", ":", "{", "level", ":", "config", ".", "level", ",", "handleExceptions", ":", "true", ",", "colorize", ":", "true", ",", "prettyPrint", ":", "true", "}", ",", "file", ":", "{", "level", ":", "config", ".", "level", ",", "filename", ":", "path", ".", "join", "(", "config", ".", "file", ".", "dir", ",", "FILE_NAME", ")", ",", "maxsize", ":", "config", ".", "file", ".", "maxsize", ",", "maxFiles", ":", "config", ".", "file", ".", "maxfiles", ",", "json", ":", "false", ",", "timestamp", ":", "true", "}", "}", ";", "transports", ".", "error", "=", "{", "filename", ":", "path", ".", "join", "(", "config", ".", "file", ".", "dir", ",", "ERROR_FILE_NAME", ")", ",", "maxsize", ":", "config", ".", "file", ".", "maxsize", ",", "maxFiles", ":", "config", ".", "file", ".", "maxfiles", ",", "timestamp", ":", "true", ",", "json", ":", "true", ",", "prettyPrint", ":", "true", "}", ";", "return", "transports", ";", "}" ]
winston transports. @param {Object} config . @return {Object} .
[ "winston", "transports", "." ]
671e8b16371a279e23b65bb9b2ff9dae047b6644
https://github.com/waka/node-bowl/blob/671e8b16371a279e23b65bb9b2ff9dae047b6644/lib/logger.js#L124-L151
57,626
ctalau/gulp-closure-builder-list
index.js
googAddDependency
function googAddDependency(file, provides, requires) { provides.forEach(function(provided) { symbolsFile[provided] = file; deps[provided] = deps[provided] || []; Array.prototype.push.apply(deps[provided], requires) }); }
javascript
function googAddDependency(file, provides, requires) { provides.forEach(function(provided) { symbolsFile[provided] = file; deps[provided] = deps[provided] || []; Array.prototype.push.apply(deps[provided], requires) }); }
[ "function", "googAddDependency", "(", "file", ",", "provides", ",", "requires", ")", "{", "provides", ".", "forEach", "(", "function", "(", "provided", ")", "{", "symbolsFile", "[", "provided", "]", "=", "file", ";", "deps", "[", "provided", "]", "=", "deps", "[", "provided", "]", "||", "[", "]", ";", "Array", ".", "prototype", ".", "push", ".", "apply", "(", "deps", "[", "provided", "]", ",", "requires", ")", "}", ")", ";", "}" ]
Replacement for goog.addDependency to just records the dependencies.
[ "Replacement", "for", "goog", ".", "addDependency", "to", "just", "records", "the", "dependencies", "." ]
b86492525561c5558fda0c7be6d7ed8bcb11e02f
https://github.com/ctalau/gulp-closure-builder-list/blob/b86492525561c5558fda0c7be6d7ed8bcb11e02f/index.js#L16-L22
57,627
ctalau/gulp-closure-builder-list
index.js
generateManifest
function generateManifest(entryPoint) { var added = new Set(); var manifest = []; function addTransitiveDeps(symbol) { added.add(symbol); var symDeps = deps[symbol]; if (symDeps) { symDeps.forEach(function(dependency) { if (!added.has(dependency)) { addTransitiveDeps(dependency); } }); } else { gutil.log('No deps found for symbol', symbol, deps); } manifest.push(symbolsFile[symbol]); } addTransitiveDeps(entryPoint); return manifest; }
javascript
function generateManifest(entryPoint) { var added = new Set(); var manifest = []; function addTransitiveDeps(symbol) { added.add(symbol); var symDeps = deps[symbol]; if (symDeps) { symDeps.forEach(function(dependency) { if (!added.has(dependency)) { addTransitiveDeps(dependency); } }); } else { gutil.log('No deps found for symbol', symbol, deps); } manifest.push(symbolsFile[symbol]); } addTransitiveDeps(entryPoint); return manifest; }
[ "function", "generateManifest", "(", "entryPoint", ")", "{", "var", "added", "=", "new", "Set", "(", ")", ";", "var", "manifest", "=", "[", "]", ";", "function", "addTransitiveDeps", "(", "symbol", ")", "{", "added", ".", "add", "(", "symbol", ")", ";", "var", "symDeps", "=", "deps", "[", "symbol", "]", ";", "if", "(", "symDeps", ")", "{", "symDeps", ".", "forEach", "(", "function", "(", "dependency", ")", "{", "if", "(", "!", "added", ".", "has", "(", "dependency", ")", ")", "{", "addTransitiveDeps", "(", "dependency", ")", ";", "}", "}", ")", ";", "}", "else", "{", "gutil", ".", "log", "(", "'No deps found for symbol'", ",", "symbol", ",", "deps", ")", ";", "}", "manifest", ".", "push", "(", "symbolsFile", "[", "symbol", "]", ")", ";", "}", "addTransitiveDeps", "(", "entryPoint", ")", ";", "return", "manifest", ";", "}" ]
Adds the transitive dependencies of the symbol to the manifest.
[ "Adds", "the", "transitive", "dependencies", "of", "the", "symbol", "to", "the", "manifest", "." ]
b86492525561c5558fda0c7be6d7ed8bcb11e02f
https://github.com/ctalau/gulp-closure-builder-list/blob/b86492525561c5558fda0c7be6d7ed8bcb11e02f/index.js#L25-L46
57,628
ctalau/gulp-closure-builder-list
index.js
generateManifestFile
function generateManifestFile() { if (Object.keys(deps).length === 0) { this.emit('end'); } else if (!entryPoint) { this.emit('error', new gutil.PluginError(PLUGIN_NAME, 'Closure entry point is not specified')); } else { var manifest = generateManifest(entryPoint); var manifestFile = new gutil.File({ contents: new Buffer(manifest.join('\n')), path: fileName }); this.emit('data', manifestFile); this.emit('end'); } }
javascript
function generateManifestFile() { if (Object.keys(deps).length === 0) { this.emit('end'); } else if (!entryPoint) { this.emit('error', new gutil.PluginError(PLUGIN_NAME, 'Closure entry point is not specified')); } else { var manifest = generateManifest(entryPoint); var manifestFile = new gutil.File({ contents: new Buffer(manifest.join('\n')), path: fileName }); this.emit('data', manifestFile); this.emit('end'); } }
[ "function", "generateManifestFile", "(", ")", "{", "if", "(", "Object", ".", "keys", "(", "deps", ")", ".", "length", "===", "0", ")", "{", "this", ".", "emit", "(", "'end'", ")", ";", "}", "else", "if", "(", "!", "entryPoint", ")", "{", "this", ".", "emit", "(", "'error'", ",", "new", "gutil", ".", "PluginError", "(", "PLUGIN_NAME", ",", "'Closure entry point is not specified'", ")", ")", ";", "}", "else", "{", "var", "manifest", "=", "generateManifest", "(", "entryPoint", ")", ";", "var", "manifestFile", "=", "new", "gutil", ".", "File", "(", "{", "contents", ":", "new", "Buffer", "(", "manifest", ".", "join", "(", "'\\n'", ")", ")", ",", "path", ":", "fileName", "}", ")", ";", "this", ".", "emit", "(", "'data'", ",", "manifestFile", ")", ";", "this", ".", "emit", "(", "'end'", ")", ";", "}", "}" ]
Generates a manifest file with one path per line.
[ "Generates", "a", "manifest", "file", "with", "one", "path", "per", "line", "." ]
b86492525561c5558fda0c7be6d7ed8bcb11e02f
https://github.com/ctalau/gulp-closure-builder-list/blob/b86492525561c5558fda0c7be6d7ed8bcb11e02f/index.js#L49-L66
57,629
nutella-framework/nutella_lib.js
src/simple-mqtt-client/client.js
connectNode
function connectNode (subscriptions, host, clientId) { // Create client var url = "tcp://" + host + ":1883"; var client = mqtt_lib.connect(url, {clientId : clientId}); // Register incoming message callback client.on('message', function(channel, message) { // Execute all the appropriate callbacks: // the ones specific to this channel with a single parameter (message) // the ones associated to a wildcard channel, with two parameters (message and channel) var cbs = findCallbacks(subscriptions, channel); if (cbs!==undefined) { cbs.forEach(function(cb) { if (Object.keys(subscriptions).indexOf(channel)!==-1) { cb(message.toString()); } else { cb(message.toString(), channel); } }); } }); return client; }
javascript
function connectNode (subscriptions, host, clientId) { // Create client var url = "tcp://" + host + ":1883"; var client = mqtt_lib.connect(url, {clientId : clientId}); // Register incoming message callback client.on('message', function(channel, message) { // Execute all the appropriate callbacks: // the ones specific to this channel with a single parameter (message) // the ones associated to a wildcard channel, with two parameters (message and channel) var cbs = findCallbacks(subscriptions, channel); if (cbs!==undefined) { cbs.forEach(function(cb) { if (Object.keys(subscriptions).indexOf(channel)!==-1) { cb(message.toString()); } else { cb(message.toString(), channel); } }); } }); return client; }
[ "function", "connectNode", "(", "subscriptions", ",", "host", ",", "clientId", ")", "{", "// Create client", "var", "url", "=", "\"tcp://\"", "+", "host", "+", "\":1883\"", ";", "var", "client", "=", "mqtt_lib", ".", "connect", "(", "url", ",", "{", "clientId", ":", "clientId", "}", ")", ";", "// Register incoming message callback", "client", ".", "on", "(", "'message'", ",", "function", "(", "channel", ",", "message", ")", "{", "// Execute all the appropriate callbacks:", "// the ones specific to this channel with a single parameter (message)", "// the ones associated to a wildcard channel, with two parameters (message and channel)", "var", "cbs", "=", "findCallbacks", "(", "subscriptions", ",", "channel", ")", ";", "if", "(", "cbs", "!==", "undefined", ")", "{", "cbs", ".", "forEach", "(", "function", "(", "cb", ")", "{", "if", "(", "Object", ".", "keys", "(", "subscriptions", ")", ".", "indexOf", "(", "channel", ")", "!==", "-", "1", ")", "{", "cb", "(", "message", ".", "toString", "(", ")", ")", ";", "}", "else", "{", "cb", "(", "message", ".", "toString", "(", ")", ",", "channel", ")", ";", "}", "}", ")", ";", "}", "}", ")", ";", "return", "client", ";", "}" ]
Helper function that connects the MQTT client in node
[ "Helper", "function", "that", "connects", "the", "MQTT", "client", "in", "node" ]
b3a3406a407e2a1ada6edcc503b70991f9cb249b
https://github.com/nutella-framework/nutella_lib.js/blob/b3a3406a407e2a1ada6edcc503b70991f9cb249b/src/simple-mqtt-client/client.js#L45-L66
57,630
nutella-framework/nutella_lib.js
src/simple-mqtt-client/client.js
subscribeNode
function subscribeNode (client, subscriptions, channel, callback, done_callback) { if (subscriptions[channel]===undefined) { subscriptions[channel] = [callback]; client.subscribe(channel, {qos: 0}, function() { // If there is a done_callback defined, execute it if (done_callback!==undefined) done_callback(); }); } else { subscriptions[channel].push(callback); } }
javascript
function subscribeNode (client, subscriptions, channel, callback, done_callback) { if (subscriptions[channel]===undefined) { subscriptions[channel] = [callback]; client.subscribe(channel, {qos: 0}, function() { // If there is a done_callback defined, execute it if (done_callback!==undefined) done_callback(); }); } else { subscriptions[channel].push(callback); } }
[ "function", "subscribeNode", "(", "client", ",", "subscriptions", ",", "channel", ",", "callback", ",", "done_callback", ")", "{", "if", "(", "subscriptions", "[", "channel", "]", "===", "undefined", ")", "{", "subscriptions", "[", "channel", "]", "=", "[", "callback", "]", ";", "client", ".", "subscribe", "(", "channel", ",", "{", "qos", ":", "0", "}", ",", "function", "(", ")", "{", "// If there is a done_callback defined, execute it", "if", "(", "done_callback", "!==", "undefined", ")", "done_callback", "(", ")", ";", "}", ")", ";", "}", "else", "{", "subscriptions", "[", "channel", "]", ".", "push", "(", "callback", ")", ";", "}", "}" ]
Helper function that subscribes to a channel in node
[ "Helper", "function", "that", "subscribes", "to", "a", "channel", "in", "node" ]
b3a3406a407e2a1ada6edcc503b70991f9cb249b
https://github.com/nutella-framework/nutella_lib.js/blob/b3a3406a407e2a1ada6edcc503b70991f9cb249b/src/simple-mqtt-client/client.js#L95-L105
57,631
nutella-framework/nutella_lib.js
src/simple-mqtt-client/client.js
function(client, subscriptions, channel, callback, done_callback) { if (subscriptions[channel]===undefined) return; subscriptions[channel].splice(subscriptions[channel].indexOf(callback), 1); if (subscriptions[channel].length===0) { delete subscriptions[channel]; client.unsubscribe(channel, function() { // If there is a done_callback defined, execute it if (done_callback!==undefined) done_callback(); }); } }
javascript
function(client, subscriptions, channel, callback, done_callback) { if (subscriptions[channel]===undefined) return; subscriptions[channel].splice(subscriptions[channel].indexOf(callback), 1); if (subscriptions[channel].length===0) { delete subscriptions[channel]; client.unsubscribe(channel, function() { // If there is a done_callback defined, execute it if (done_callback!==undefined) done_callback(); }); } }
[ "function", "(", "client", ",", "subscriptions", ",", "channel", ",", "callback", ",", "done_callback", ")", "{", "if", "(", "subscriptions", "[", "channel", "]", "===", "undefined", ")", "return", ";", "subscriptions", "[", "channel", "]", ".", "splice", "(", "subscriptions", "[", "channel", "]", ".", "indexOf", "(", "callback", ")", ",", "1", ")", ";", "if", "(", "subscriptions", "[", "channel", "]", ".", "length", "===", "0", ")", "{", "delete", "subscriptions", "[", "channel", "]", ";", "client", ".", "unsubscribe", "(", "channel", ",", "function", "(", ")", "{", "// If there is a done_callback defined, execute it", "if", "(", "done_callback", "!==", "undefined", ")", "done_callback", "(", ")", ";", "}", ")", ";", "}", "}" ]
Helper function that unsubscribes from a channel in node
[ "Helper", "function", "that", "unsubscribes", "from", "a", "channel", "in", "node" ]
b3a3406a407e2a1ada6edcc503b70991f9cb249b
https://github.com/nutella-framework/nutella_lib.js/blob/b3a3406a407e2a1ada6edcc503b70991f9cb249b/src/simple-mqtt-client/client.js#L123-L134
57,632
gristlabs/collect-js-deps
index.js
replaceExt
function replaceExt(fpath, newExt) { const oldExt = path.extname(fpath); return _nativeExt.includes(oldExt) ? fpath : path.join(path.dirname(fpath), path.basename(fpath, oldExt) + newExt); }
javascript
function replaceExt(fpath, newExt) { const oldExt = path.extname(fpath); return _nativeExt.includes(oldExt) ? fpath : path.join(path.dirname(fpath), path.basename(fpath, oldExt) + newExt); }
[ "function", "replaceExt", "(", "fpath", ",", "newExt", ")", "{", "const", "oldExt", "=", "path", ".", "extname", "(", "fpath", ")", ";", "return", "_nativeExt", ".", "includes", "(", "oldExt", ")", "?", "fpath", ":", "path", ".", "join", "(", "path", ".", "dirname", "(", "fpath", ")", ",", "path", ".", "basename", "(", "fpath", ",", "oldExt", ")", "+", "newExt", ")", ";", "}" ]
Replaces extension of fpath with newExt unless fpath has a .js or .json extension.
[ "Replaces", "extension", "of", "fpath", "with", "newExt", "unless", "fpath", "has", "a", ".", "js", "or", ".", "json", "extension", "." ]
cc7c58e38acb03b150d260bf1b39f76b9e95e5cc
https://github.com/gristlabs/collect-js-deps/blob/cc7c58e38acb03b150d260bf1b39f76b9e95e5cc/index.js#L14-L18
57,633
gristlabs/collect-js-deps
index.js
main
function main(args) { return new Promise((resolve, reject) => { let b = browserifyArgs(['--node', '--no-detect-globals'].concat(args)); let outdir = (b.argv.outdir || b.argv.o); if (b.argv._[0] === 'help' || b.argv.h || b.argv.help || (process.argv.length <= 2 && process.stdin.isTTY)) { reject(new Error('Usage: collect-js-deps --outdir <path> [--list] ' + '{BROWSERIFY-OPTIONS} [entry files]')); return; } if (!outdir && !b.argv.list) { reject(new Error('collect-js-deps requires --outdir (-o) option for output directory, or --list')); return; } collect_js_deps(b, { list: b.argv.list, outdir }); b.bundle((err, body) => err ? reject(err) : resolve()); }); }
javascript
function main(args) { return new Promise((resolve, reject) => { let b = browserifyArgs(['--node', '--no-detect-globals'].concat(args)); let outdir = (b.argv.outdir || b.argv.o); if (b.argv._[0] === 'help' || b.argv.h || b.argv.help || (process.argv.length <= 2 && process.stdin.isTTY)) { reject(new Error('Usage: collect-js-deps --outdir <path> [--list] ' + '{BROWSERIFY-OPTIONS} [entry files]')); return; } if (!outdir && !b.argv.list) { reject(new Error('collect-js-deps requires --outdir (-o) option for output directory, or --list')); return; } collect_js_deps(b, { list: b.argv.list, outdir }); b.bundle((err, body) => err ? reject(err) : resolve()); }); }
[ "function", "main", "(", "args", ")", "{", "return", "new", "Promise", "(", "(", "resolve", ",", "reject", ")", "=>", "{", "let", "b", "=", "browserifyArgs", "(", "[", "'--node'", ",", "'--no-detect-globals'", "]", ".", "concat", "(", "args", ")", ")", ";", "let", "outdir", "=", "(", "b", ".", "argv", ".", "outdir", "||", "b", ".", "argv", ".", "o", ")", ";", "if", "(", "b", ".", "argv", ".", "_", "[", "0", "]", "===", "'help'", "||", "b", ".", "argv", ".", "h", "||", "b", ".", "argv", ".", "help", "||", "(", "process", ".", "argv", ".", "length", "<=", "2", "&&", "process", ".", "stdin", ".", "isTTY", ")", ")", "{", "reject", "(", "new", "Error", "(", "'Usage: collect-js-deps --outdir <path> [--list] '", "+", "'{BROWSERIFY-OPTIONS} [entry files]'", ")", ")", ";", "return", ";", "}", "if", "(", "!", "outdir", "&&", "!", "b", ".", "argv", ".", "list", ")", "{", "reject", "(", "new", "Error", "(", "'collect-js-deps requires --outdir (-o) option for output directory, or --list'", ")", ")", ";", "return", ";", "}", "collect_js_deps", "(", "b", ",", "{", "list", ":", "b", ".", "argv", ".", "list", ",", "outdir", "}", ")", ";", "b", ".", "bundle", "(", "(", "err", ",", "body", ")", "=>", "err", "?", "reject", "(", "err", ")", ":", "resolve", "(", ")", ")", ";", "}", ")", ";", "}" ]
Command-line interface to collect_js_deps. Takes an array of arguments as may be passed to collect-js-deps on the command-line. @returns Promise resolved on success, rejected on error.
[ "Command", "-", "line", "interface", "to", "collect_js_deps", ".", "Takes", "an", "array", "of", "arguments", "as", "may", "be", "passed", "to", "collect", "-", "js", "-", "deps", "on", "the", "command", "-", "line", "." ]
cc7c58e38acb03b150d260bf1b39f76b9e95e5cc
https://github.com/gristlabs/collect-js-deps/blob/cc7c58e38acb03b150d260bf1b39f76b9e95e5cc/index.js#L108-L125
57,634
char1e5/ot-webdriverjs
chrome.js
createDriver
function createDriver(opt_options, opt_service) { var service = opt_service || getDefaultService(); var executor = executors.createExecutor(service.start()); var options = opt_options || new Options(); if (opt_options instanceof webdriver.Capabilities) { // Extract the Chrome-specific options so we do not send unnecessary // data across the wire. options = Options.fromCapabilities(options); } return webdriver.WebDriver.createSession( executor, options.toCapabilities()); }
javascript
function createDriver(opt_options, opt_service) { var service = opt_service || getDefaultService(); var executor = executors.createExecutor(service.start()); var options = opt_options || new Options(); if (opt_options instanceof webdriver.Capabilities) { // Extract the Chrome-specific options so we do not send unnecessary // data across the wire. options = Options.fromCapabilities(options); } return webdriver.WebDriver.createSession( executor, options.toCapabilities()); }
[ "function", "createDriver", "(", "opt_options", ",", "opt_service", ")", "{", "var", "service", "=", "opt_service", "||", "getDefaultService", "(", ")", ";", "var", "executor", "=", "executors", ".", "createExecutor", "(", "service", ".", "start", "(", ")", ")", ";", "var", "options", "=", "opt_options", "||", "new", "Options", "(", ")", ";", "if", "(", "opt_options", "instanceof", "webdriver", ".", "Capabilities", ")", "{", "// Extract the Chrome-specific options so we do not send unnecessary", "// data across the wire.", "options", "=", "Options", ".", "fromCapabilities", "(", "options", ")", ";", "}", "return", "webdriver", ".", "WebDriver", ".", "createSession", "(", "executor", ",", "options", ".", "toCapabilities", "(", ")", ")", ";", "}" ]
Creates a new ChromeDriver session. @param {(webdriver.Capabilities|Options)=} opt_options The session options. @param {remote.DriverService=} opt_service The session to use; will use the {@link getDefaultService default service} by default. @return {!webdriver.WebDriver} A new WebDriver instance.
[ "Creates", "a", "new", "ChromeDriver", "session", "." ]
5fc8cabcb481602673f1d47cdf544d681c35f784
https://github.com/char1e5/ot-webdriverjs/blob/5fc8cabcb481602673f1d47cdf544d681c35f784/chrome.js#L449-L462
57,635
mcccclean/node-gamesprites
lib/spritesheet.js
rectshift
function rectshift(a, b) { if(a.x > b.x + b.width || a.x + a.width < b.x || a.y > b.y + b.height || a.y + a.height < b.y) { return 0; } else { var overlap = b.x + b.width - a.x; return overlap; } }
javascript
function rectshift(a, b) { if(a.x > b.x + b.width || a.x + a.width < b.x || a.y > b.y + b.height || a.y + a.height < b.y) { return 0; } else { var overlap = b.x + b.width - a.x; return overlap; } }
[ "function", "rectshift", "(", "a", ",", "b", ")", "{", "if", "(", "a", ".", "x", ">", "b", ".", "x", "+", "b", ".", "width", "||", "a", ".", "x", "+", "a", ".", "width", "<", "b", ".", "x", "||", "a", ".", "y", ">", "b", ".", "y", "+", "b", ".", "height", "||", "a", ".", "y", "+", "a", ".", "height", "<", "b", ".", "y", ")", "{", "return", "0", ";", "}", "else", "{", "var", "overlap", "=", "b", ".", "x", "+", "b", ".", "width", "-", "a", ".", "x", ";", "return", "overlap", ";", "}", "}" ]
see if two rectangles overlap. if so, return the distance that A needs to shift to the right to avoid overlapping.
[ "see", "if", "two", "rectangles", "overlap", ".", "if", "so", "return", "the", "distance", "that", "A", "needs", "to", "shift", "to", "the", "right", "to", "avoid", "overlapping", "." ]
9c430065cda394c82f8074b7bf6b07ff807c1431
https://github.com/mcccclean/node-gamesprites/blob/9c430065cda394c82f8074b7bf6b07ff807c1431/lib/spritesheet.js#L10-L20
57,636
Pocketbrain/native-ads-web-ad-library
src/util/crossDomainStorage.js
function () { this.isReady = false; this._requestID = -1; this._iframe = null; this._initCallback = null; this._requests = {}; this._options = { iframeID: "pm-lib-iframe" }; }
javascript
function () { this.isReady = false; this._requestID = -1; this._iframe = null; this._initCallback = null; this._requests = {}; this._options = { iframeID: "pm-lib-iframe" }; }
[ "function", "(", ")", "{", "this", ".", "isReady", "=", "false", ";", "this", ".", "_requestID", "=", "-", "1", ";", "this", ".", "_iframe", "=", "null", ";", "this", ".", "_initCallback", "=", "null", ";", "this", ".", "_requests", "=", "{", "}", ";", "this", ".", "_options", "=", "{", "iframeID", ":", "\"pm-lib-iframe\"", "}", ";", "}" ]
Create a new instance of the CrossDomainStorage object @constructor
[ "Create", "a", "new", "instance", "of", "the", "CrossDomainStorage", "object" ]
aafee1c42e0569ee77f334fc2c4eb71eb146957e
https://github.com/Pocketbrain/native-ads-web-ad-library/blob/aafee1c42e0569ee77f334fc2c4eb71eb146957e/src/util/crossDomainStorage.js#L29-L39
57,637
Schoonology/once-later
later.js
long
function long(callback) { var called = false return function cbOnceLater() { var args if (called) { return } called = true args = Array.prototype.slice.call(arguments) process.nextTick(function () { callback.apply(null, args) }) } }
javascript
function long(callback) { var called = false return function cbOnceLater() { var args if (called) { return } called = true args = Array.prototype.slice.call(arguments) process.nextTick(function () { callback.apply(null, args) }) } }
[ "function", "long", "(", "callback", ")", "{", "var", "called", "=", "false", "return", "function", "cbOnceLater", "(", ")", "{", "var", "args", "if", "(", "called", ")", "{", "return", "}", "called", "=", "true", "args", "=", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ")", "process", ".", "nextTick", "(", "function", "(", ")", "{", "callback", ".", "apply", "(", "null", ",", "args", ")", "}", ")", "}", "}" ]
Slower, uncommon version
[ "Slower", "uncommon", "version" ]
0b2fd2c144d727a71534db32f075491051974c19
https://github.com/Schoonology/once-later/blob/0b2fd2c144d727a71534db32f075491051974c19/later.js#L5-L22
57,638
Schoonology/once-later
later.js
short
function short(callback) { var called = false return function cbOnceLater(err, data) { if (called) { return } called = true process.nextTick(function () { callback(err, data) }) } }
javascript
function short(callback) { var called = false return function cbOnceLater(err, data) { if (called) { return } called = true process.nextTick(function () { callback(err, data) }) } }
[ "function", "short", "(", "callback", ")", "{", "var", "called", "=", "false", "return", "function", "cbOnceLater", "(", "err", ",", "data", ")", "{", "if", "(", "called", ")", "{", "return", "}", "called", "=", "true", "process", ".", "nextTick", "(", "function", "(", ")", "{", "callback", "(", "err", ",", "data", ")", "}", ")", "}", "}" ]
Faster, common version
[ "Faster", "common", "version" ]
0b2fd2c144d727a71534db32f075491051974c19
https://github.com/Schoonology/once-later/blob/0b2fd2c144d727a71534db32f075491051974c19/later.js#L25-L39
57,639
DmitryMyadzelets/u-machine
index.js
constructor
function constructor(o) { var f = main.bind(o); o.current = o.states.initial || o.initial(); o.machine = f; return f; }
javascript
function constructor(o) { var f = main.bind(o); o.current = o.states.initial || o.initial(); o.machine = f; return f; }
[ "function", "constructor", "(", "o", ")", "{", "var", "f", "=", "main", ".", "bind", "(", "o", ")", ";", "o", ".", "current", "=", "o", ".", "states", ".", "initial", "||", "o", ".", "initial", "(", ")", ";", "o", ".", "machine", "=", "f", ";", "return", "f", ";", "}" ]
Returns the machine object main function. Sets the initial state as current
[ "Returns", "the", "machine", "object", "main", "function", ".", "Sets", "the", "initial", "state", "as", "current" ]
1a01636b0211abc148feeda4108383d93368c4c7
https://github.com/DmitryMyadzelets/u-machine/blob/1a01636b0211abc148feeda4108383d93368c4c7/index.js#L39-L44
57,640
Knorcedger/reqlog
index.js
log
function log(type, label, data) { var typeLabel = type.charAt(0).toUpperCase() + type.slice(1); var color; if (typeLabel === 'Error') { typeLabel = chalk.red(typeLabel); color = 'red'; } else if (typeLabel === 'Warn') { typeLabel = chalk.yellow(typeLabel); color = 'yellow'; } else if (typeLabel === 'Info') { typeLabel = chalk.green(typeLabel); color = 'green'; } else if (typeLabel === 'Log') { typeLabel = chalk.gray(typeLabel); color = 'gray'; } // used to avoid logging "undefined" in the console if (useTypeLabels) { label = typeLabel + ': ' + chalk.cyan(label); } else { label = chalk[color](label); } if (data) { console[type](label, data); } else { console[type](label); } }
javascript
function log(type, label, data) { var typeLabel = type.charAt(0).toUpperCase() + type.slice(1); var color; if (typeLabel === 'Error') { typeLabel = chalk.red(typeLabel); color = 'red'; } else if (typeLabel === 'Warn') { typeLabel = chalk.yellow(typeLabel); color = 'yellow'; } else if (typeLabel === 'Info') { typeLabel = chalk.green(typeLabel); color = 'green'; } else if (typeLabel === 'Log') { typeLabel = chalk.gray(typeLabel); color = 'gray'; } // used to avoid logging "undefined" in the console if (useTypeLabels) { label = typeLabel + ': ' + chalk.cyan(label); } else { label = chalk[color](label); } if (data) { console[type](label, data); } else { console[type](label); } }
[ "function", "log", "(", "type", ",", "label", ",", "data", ")", "{", "var", "typeLabel", "=", "type", ".", "charAt", "(", "0", ")", ".", "toUpperCase", "(", ")", "+", "type", ".", "slice", "(", "1", ")", ";", "var", "color", ";", "if", "(", "typeLabel", "===", "'Error'", ")", "{", "typeLabel", "=", "chalk", ".", "red", "(", "typeLabel", ")", ";", "color", "=", "'red'", ";", "}", "else", "if", "(", "typeLabel", "===", "'Warn'", ")", "{", "typeLabel", "=", "chalk", ".", "yellow", "(", "typeLabel", ")", ";", "color", "=", "'yellow'", ";", "}", "else", "if", "(", "typeLabel", "===", "'Info'", ")", "{", "typeLabel", "=", "chalk", ".", "green", "(", "typeLabel", ")", ";", "color", "=", "'green'", ";", "}", "else", "if", "(", "typeLabel", "===", "'Log'", ")", "{", "typeLabel", "=", "chalk", ".", "gray", "(", "typeLabel", ")", ";", "color", "=", "'gray'", ";", "}", "// used to avoid logging \"undefined\" in the console", "if", "(", "useTypeLabels", ")", "{", "label", "=", "typeLabel", "+", "': '", "+", "chalk", ".", "cyan", "(", "label", ")", ";", "}", "else", "{", "label", "=", "chalk", "[", "color", "]", "(", "label", ")", ";", "}", "if", "(", "data", ")", "{", "console", "[", "type", "]", "(", "label", ",", "data", ")", ";", "}", "else", "{", "console", "[", "type", "]", "(", "label", ")", ";", "}", "}" ]
Beutifies the log data and logs! @method log @param {string} type The log type @param {string} label The log label @param {any} data The data to display next to the label (optional)
[ "Beutifies", "the", "log", "data", "and", "logs!" ]
feb9d7faef81f384aa7d60183211c54fe6af3ee6
https://github.com/Knorcedger/reqlog/blob/feb9d7faef81f384aa7d60183211c54fe6af3ee6/index.js#L14-L43
57,641
antonycourtney/tabli-core
lib/js/actions.js
syncChromeWindowById
function syncChromeWindowById(windowId, cb) { chrome.windows.get(windowId, { populate: true }, function (chromeWindow) { cb(function (state) { return state.syncChromeWindow(chromeWindow); }); }); }
javascript
function syncChromeWindowById(windowId, cb) { chrome.windows.get(windowId, { populate: true }, function (chromeWindow) { cb(function (state) { return state.syncChromeWindow(chromeWindow); }); }); }
[ "function", "syncChromeWindowById", "(", "windowId", ",", "cb", ")", "{", "chrome", ".", "windows", ".", "get", "(", "windowId", ",", "{", "populate", ":", "true", "}", ",", "function", "(", "chromeWindow", ")", "{", "cb", "(", "function", "(", "state", ")", "{", "return", "state", ".", "syncChromeWindow", "(", "chromeWindow", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
sync a single Chrome window by its Chrome window id @param {function} cb -- callback to update state
[ "sync", "a", "single", "Chrome", "window", "by", "its", "Chrome", "window", "id" ]
76cc540891421bc6c8bdcf00f277ebb6e716fdd9
https://github.com/antonycourtney/tabli-core/blob/76cc540891421bc6c8bdcf00f277ebb6e716fdd9/lib/js/actions.js#L36-L42
57,642
PrinceNebulon/github-api-promise
src/issues/comments.js
function(owner, repo, params) { return req.standardRequest(`${config.host}/repos/${owner}/${repo}/issues/comments?${req.assembleQueryParams(params, ['sort', 'direction', 'since'])}`); }
javascript
function(owner, repo, params) { return req.standardRequest(`${config.host}/repos/${owner}/${repo}/issues/comments?${req.assembleQueryParams(params, ['sort', 'direction', 'since'])}`); }
[ "function", "(", "owner", ",", "repo", ",", "params", ")", "{", "return", "req", ".", "standardRequest", "(", "`", "${", "config", ".", "host", "}", "${", "owner", "}", "${", "repo", "}", "${", "req", ".", "assembleQueryParams", "(", "params", ",", "[", "'sort'", ",", "'direction'", ",", "'since'", "]", ")", "}", "`", ")", ";", "}" ]
List comments in a repository By default, Issue Comments are ordered by ascending ID. @see {@link https://developer.github.com/v3/issues/comments/#list-comments-in-a-repository} @param {string} owner - The repo's owner @param {string} repo - The repo's name @param {object} params - An object of parameters for the request @param {int} params.sort - Either created or updated. Default: created @param {int} params.direction - Either asc or desc. Ignored without the sort parameter. @param {int} params.since - Only comments updated at or after this time are returned. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. @return {object} Comment data
[ "List", "comments", "in", "a", "repository", "By", "default", "Issue", "Comments", "are", "ordered", "by", "ascending", "ID", "." ]
990cb2cce19b53f54d9243002fde47428f24e7cc
https://github.com/PrinceNebulon/github-api-promise/blob/990cb2cce19b53f54d9243002fde47428f24e7cc/src/issues/comments.js#L45-L48
57,643
PrinceNebulon/github-api-promise
src/issues/comments.js
function(owner, repo, id) { return req.standardRequest(`${config.host}/repos/${owner}/${repo}/issues/comments/${id}`); }
javascript
function(owner, repo, id) { return req.standardRequest(`${config.host}/repos/${owner}/${repo}/issues/comments/${id}`); }
[ "function", "(", "owner", ",", "repo", ",", "id", ")", "{", "return", "req", ".", "standardRequest", "(", "`", "${", "config", ".", "host", "}", "${", "owner", "}", "${", "repo", "}", "${", "id", "}", "`", ")", ";", "}" ]
Get a single comment @see {@link https://developer.github.com/v3/issues/comments/#get-a-single-comment} @param {string} owner - The repo's owner @param {string} repo - The repo's name @param {string} id - The comment id @return {object} Comment data
[ "Get", "a", "single", "comment" ]
990cb2cce19b53f54d9243002fde47428f24e7cc
https://github.com/PrinceNebulon/github-api-promise/blob/990cb2cce19b53f54d9243002fde47428f24e7cc/src/issues/comments.js#L61-L63
57,644
75lb/object-tools
lib/object-tools.js
extend
function extend () { var depth = 0 var args = arrayify(arguments) if (!args.length) return {} var last = args[args.length - 1] if (t.isPlainObject(last) && '__depth' in last) { depth = last.__depth args.pop() } return args.reduce(function (output, curr) { if (typeof curr !== 'object') return output for (var prop in curr) { var value = curr[prop] if (value === undefined) break if (t.isObject(value) && !Array.isArray(value) && depth < 10) { if (!output[prop]) output[prop] = {} output[prop] = extend(output[prop], value, { __depth: ++depth }) } else { output[prop] = value } } return output }, {}) }
javascript
function extend () { var depth = 0 var args = arrayify(arguments) if (!args.length) return {} var last = args[args.length - 1] if (t.isPlainObject(last) && '__depth' in last) { depth = last.__depth args.pop() } return args.reduce(function (output, curr) { if (typeof curr !== 'object') return output for (var prop in curr) { var value = curr[prop] if (value === undefined) break if (t.isObject(value) && !Array.isArray(value) && depth < 10) { if (!output[prop]) output[prop] = {} output[prop] = extend(output[prop], value, { __depth: ++depth }) } else { output[prop] = value } } return output }, {}) }
[ "function", "extend", "(", ")", "{", "var", "depth", "=", "0", "var", "args", "=", "arrayify", "(", "arguments", ")", "if", "(", "!", "args", ".", "length", ")", "return", "{", "}", "var", "last", "=", "args", "[", "args", ".", "length", "-", "1", "]", "if", "(", "t", ".", "isPlainObject", "(", "last", ")", "&&", "'__depth'", "in", "last", ")", "{", "depth", "=", "last", ".", "__depth", "args", ".", "pop", "(", ")", "}", "return", "args", ".", "reduce", "(", "function", "(", "output", ",", "curr", ")", "{", "if", "(", "typeof", "curr", "!==", "'object'", ")", "return", "output", "for", "(", "var", "prop", "in", "curr", ")", "{", "var", "value", "=", "curr", "[", "prop", "]", "if", "(", "value", "===", "undefined", ")", "break", "if", "(", "t", ".", "isObject", "(", "value", ")", "&&", "!", "Array", ".", "isArray", "(", "value", ")", "&&", "depth", "<", "10", ")", "{", "if", "(", "!", "output", "[", "prop", "]", ")", "output", "[", "prop", "]", "=", "{", "}", "output", "[", "prop", "]", "=", "extend", "(", "output", "[", "prop", "]", ",", "value", ",", "{", "__depth", ":", "++", "depth", "}", ")", "}", "else", "{", "output", "[", "prop", "]", "=", "value", "}", "}", "return", "output", "}", ",", "{", "}", ")", "}" ]
Merge a list of objects, left to right, into one - to a maximum depth of 10. @param {...object} object - a sequence of object instances to be extended @returns {object} @static @example > o.extend({ one: 1, three: 3 }, { one: 'one', two: 2 }, { four: 4 }) { one: 'one', three: 3, two: 2, four: 4 }
[ "Merge", "a", "list", "of", "objects", "left", "to", "right", "into", "one", "-", "to", "a", "maximum", "depth", "of", "10", "." ]
4eca0070f327e643d2a08d3adc838e99db33e953
https://github.com/75lb/object-tools/blob/4eca0070f327e643d2a08d3adc838e99db33e953/lib/object-tools.js#L38-L61
57,645
75lb/object-tools
lib/object-tools.js
clone
function clone (input) { var output if (typeof input === 'object' && !Array.isArray(input) && input !== null) { output = {} for (var prop in input) { output[prop] = input[prop] } return output } else if (Array.isArray(input)) { output = [] input.forEach(function (item) { output.push(clone(item)) }) return output } else { return input } }
javascript
function clone (input) { var output if (typeof input === 'object' && !Array.isArray(input) && input !== null) { output = {} for (var prop in input) { output[prop] = input[prop] } return output } else if (Array.isArray(input)) { output = [] input.forEach(function (item) { output.push(clone(item)) }) return output } else { return input } }
[ "function", "clone", "(", "input", ")", "{", "var", "output", "if", "(", "typeof", "input", "===", "'object'", "&&", "!", "Array", ".", "isArray", "(", "input", ")", "&&", "input", "!==", "null", ")", "{", "output", "=", "{", "}", "for", "(", "var", "prop", "in", "input", ")", "{", "output", "[", "prop", "]", "=", "input", "[", "prop", "]", "}", "return", "output", "}", "else", "if", "(", "Array", ".", "isArray", "(", "input", ")", ")", "{", "output", "=", "[", "]", "input", ".", "forEach", "(", "function", "(", "item", ")", "{", "output", ".", "push", "(", "clone", "(", "item", ")", ")", "}", ")", "return", "output", "}", "else", "{", "return", "input", "}", "}" ]
Clones an object or array @param {object|array} input - the input to clone @returns {object|array} @static @example > date = new Date() Fri May 09 2014 13:54:34 GMT+0200 (CEST) > o.clone(date) {} // a Date instance doesn't own any properties > date.clive = 'hater' 'hater' > o.clone(date) { clive: 'hater' } > array = [1,2,3] [ 1, 2, 3 ] > newArray = o.clone(array) [ 1, 2, 3 ] > array === newArray false
[ "Clones", "an", "object", "or", "array" ]
4eca0070f327e643d2a08d3adc838e99db33e953
https://github.com/75lb/object-tools/blob/4eca0070f327e643d2a08d3adc838e99db33e953/lib/object-tools.js#L84-L101
57,646
75lb/object-tools
lib/object-tools.js
every
function every (object, iterator) { var result = true for (var prop in object) { result = result && iterator(object[prop], prop) } return result }
javascript
function every (object, iterator) { var result = true for (var prop in object) { result = result && iterator(object[prop], prop) } return result }
[ "function", "every", "(", "object", ",", "iterator", ")", "{", "var", "result", "=", "true", "for", "(", "var", "prop", "in", "object", ")", "{", "result", "=", "result", "&&", "iterator", "(", "object", "[", "prop", "]", ",", "prop", ")", "}", "return", "result", "}" ]
Returns true if the supplied iterator function returns true for every property in the object @param {object} - the object to inspect @param {Function} - the iterator function to run against each key/value pair, the args are `(value, key)`. @returns {boolean} @static @example > function aboveTen(input){ return input > 10; } > o.every({ eggs: 12, carrots: 30, peas: 100 }, aboveTen) true > o.every({ eggs: 6, carrots: 30, peas: 100 }, aboveTen) false
[ "Returns", "true", "if", "the", "supplied", "iterator", "function", "returns", "true", "for", "every", "property", "in", "the", "object" ]
4eca0070f327e643d2a08d3adc838e99db33e953
https://github.com/75lb/object-tools/blob/4eca0070f327e643d2a08d3adc838e99db33e953/lib/object-tools.js#L116-L122
57,647
icemobilelab/virgilio-http
lib/virgilio-http.js
HandlerChain
function HandlerChain() { var handlers = this._handlers = []; //`handlerChain.handlers` is a promised for the handlers that will be //resolved in the nextTick, to give the user time to call `addHandler`. this.handlers = new Promise(function(resolve) { //Give the user time to register some handlers process.nextTick(function() { resolve(handlers); }); }); }
javascript
function HandlerChain() { var handlers = this._handlers = []; //`handlerChain.handlers` is a promised for the handlers that will be //resolved in the nextTick, to give the user time to call `addHandler`. this.handlers = new Promise(function(resolve) { //Give the user time to register some handlers process.nextTick(function() { resolve(handlers); }); }); }
[ "function", "HandlerChain", "(", ")", "{", "var", "handlers", "=", "this", ".", "_handlers", "=", "[", "]", ";", "//`handlerChain.handlers` is a promised for the handlers that will be", "//resolved in the nextTick, to give the user time to call `addHandler`.", "this", ".", "handlers", "=", "new", "Promise", "(", "function", "(", "resolve", ")", "{", "//Give the user time to register some handlers", "process", ".", "nextTick", "(", "function", "(", ")", "{", "resolve", "(", "handlers", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
The `HandlerChain` constructor returns an object with an `addHandler` method. This can be called in chain several times to register handlers.
[ "The", "HandlerChain", "constructor", "returns", "an", "object", "with", "an", "addHandler", "method", ".", "This", "can", "be", "called", "in", "chain", "several", "times", "to", "register", "handlers", "." ]
3585a7cbabb16449f84d3f02a0756f03e699de2b
https://github.com/icemobilelab/virgilio-http/blob/3585a7cbabb16449f84d3f02a0756f03e699de2b/lib/virgilio-http.js#L52-L62
57,648
icemobilelab/virgilio-http
lib/virgilio-http.js
restifyHandler
function restifyHandler(handler, req, res, next) { Promise.method(handler).call(this, req, res) .then(function(result) { next(result); }) .catch(function(error) { //FIXME ensure error is an error instance. next(error); }); }
javascript
function restifyHandler(handler, req, res, next) { Promise.method(handler).call(this, req, res) .then(function(result) { next(result); }) .catch(function(error) { //FIXME ensure error is an error instance. next(error); }); }
[ "function", "restifyHandler", "(", "handler", ",", "req", ",", "res", ",", "next", ")", "{", "Promise", ".", "method", "(", "handler", ")", ".", "call", "(", "this", ",", "req", ",", "res", ")", ".", "then", "(", "function", "(", "result", ")", "{", "next", "(", "result", ")", ";", "}", ")", ".", "catch", "(", "function", "(", "error", ")", "{", "//FIXME ensure error is an error instance.", "next", "(", "error", ")", ";", "}", ")", ";", "}" ]
The `restifyHandler` will be registered with the restify server, after partially applying the `handler` arg.
[ "The", "restifyHandler", "will", "be", "registered", "with", "the", "restify", "server", "after", "partially", "applying", "the", "handler", "arg", "." ]
3585a7cbabb16449f84d3f02a0756f03e699de2b
https://github.com/icemobilelab/virgilio-http/blob/3585a7cbabb16449f84d3f02a0756f03e699de2b/lib/virgilio-http.js#L110-L119
57,649
icemobilelab/virgilio-http
lib/virgilio-http.js
paramsFromRegexPath
function paramsFromRegexPath(paramsObj) { var paramNames = Object.keys(paramsObj); var params = paramNames.reduce(function(params, paramName) { if ((/^\d+$/).test(paramName)) { params.push(paramsObj[paramName]); } return params; }, []); return params; }
javascript
function paramsFromRegexPath(paramsObj) { var paramNames = Object.keys(paramsObj); var params = paramNames.reduce(function(params, paramName) { if ((/^\d+$/).test(paramName)) { params.push(paramsObj[paramName]); } return params; }, []); return params; }
[ "function", "paramsFromRegexPath", "(", "paramsObj", ")", "{", "var", "paramNames", "=", "Object", ".", "keys", "(", "paramsObj", ")", ";", "var", "params", "=", "paramNames", ".", "reduce", "(", "function", "(", "params", ",", "paramName", ")", "{", "if", "(", "(", "/", "^\\d+$", "/", ")", ".", "test", "(", "paramName", ")", ")", "{", "params", ".", "push", "(", "paramsObj", "[", "paramName", "]", ")", ";", "}", "return", "params", ";", "}", ",", "[", "]", ")", ";", "return", "params", ";", "}" ]
Given a certain paramsObj resulting from a regex path, create an array of parameters. Note that in this instance `req.params` is an object with numerical properties for the regex matches.
[ "Given", "a", "certain", "paramsObj", "resulting", "from", "a", "regex", "path", "create", "an", "array", "of", "parameters", ".", "Note", "that", "in", "this", "instance", "req", ".", "params", "is", "an", "object", "with", "numerical", "properties", "for", "the", "regex", "matches", "." ]
3585a7cbabb16449f84d3f02a0756f03e699de2b
https://github.com/icemobilelab/virgilio-http/blob/3585a7cbabb16449f84d3f02a0756f03e699de2b/lib/virgilio-http.js#L155-L164
57,650
Wiredcraft/carcass-config
proto/consumer.js
function() { var manager, name; manager = this.configManager(); if (manager == null) { return; } name = this.configName(); if (name == null) { return; } return manager.get(name); }
javascript
function() { var manager, name; manager = this.configManager(); if (manager == null) { return; } name = this.configName(); if (name == null) { return; } return manager.get(name); }
[ "function", "(", ")", "{", "var", "manager", ",", "name", ";", "manager", "=", "this", ".", "configManager", "(", ")", ";", "if", "(", "manager", "==", "null", ")", "{", "return", ";", "}", "name", "=", "this", ".", "configName", "(", ")", ";", "if", "(", "name", "==", "null", ")", "{", "return", ";", "}", "return", "manager", ".", "get", "(", "name", ")", ";", "}" ]
Retrieve config.
[ "Retrieve", "config", "." ]
bb1dce284acfb40d2c23a989fe7b5ee4e2221bab
https://github.com/Wiredcraft/carcass-config/blob/bb1dce284acfb40d2c23a989fe7b5ee4e2221bab/proto/consumer.js#L41-L52
57,651
5long/roil
src/console/simpleyui.js
function() { var i = 0, Y = this, args = arguments, l = args.length, gconf = (typeof YUI_config !== 'undefined') && YUI_config; if (!(Y instanceof YUI)) { Y = new YUI(); } else { // set up the core environment Y._init(); if (gconf) { Y.applyConfig(gconf); } // bind the specified additional modules for this instance if (!l) { Y._setup(); } } if (l) { for (; i<l; i++) { Y.applyConfig(args[i]); } Y._setup(); } return Y; }
javascript
function() { var i = 0, Y = this, args = arguments, l = args.length, gconf = (typeof YUI_config !== 'undefined') && YUI_config; if (!(Y instanceof YUI)) { Y = new YUI(); } else { // set up the core environment Y._init(); if (gconf) { Y.applyConfig(gconf); } // bind the specified additional modules for this instance if (!l) { Y._setup(); } } if (l) { for (; i<l; i++) { Y.applyConfig(args[i]); } Y._setup(); } return Y; }
[ "function", "(", ")", "{", "var", "i", "=", "0", ",", "Y", "=", "this", ",", "args", "=", "arguments", ",", "l", "=", "args", ".", "length", ",", "gconf", "=", "(", "typeof", "YUI_config", "!==", "'undefined'", ")", "&&", "YUI_config", ";", "if", "(", "!", "(", "Y", "instanceof", "YUI", ")", ")", "{", "Y", "=", "new", "YUI", "(", ")", ";", "}", "else", "{", "// set up the core environment", "Y", ".", "_init", "(", ")", ";", "if", "(", "gconf", ")", "{", "Y", ".", "applyConfig", "(", "gconf", ")", ";", "}", "// bind the specified additional modules for this instance", "if", "(", "!", "l", ")", "{", "Y", ".", "_setup", "(", ")", ";", "}", "}", "if", "(", "l", ")", "{", "for", "(", ";", "i", "<", "l", ";", "i", "++", ")", "{", "Y", ".", "applyConfig", "(", "args", "[", "i", "]", ")", ";", "}", "Y", ".", "_setup", "(", ")", ";", "}", "return", "Y", ";", "}" ]
The YUI global namespace object. If YUI is already defined, the existing YUI object will not be overwritten so that defined namespaces are preserved. It is the constructor for the object the end user interacts with. As indicated below, each instance has full custom event support, but only if the event system is available. @class YUI @constructor @global @uses EventTarget @param o* 0..n optional configuration objects. these values are store in Y.config. See config for the list of supported properties. /*global YUI /*global YUI_config
[ "The", "YUI", "global", "namespace", "object", ".", "If", "YUI", "is", "already", "defined", "the", "existing", "YUI", "object", "will", "not", "be", "overwritten", "so", "that", "defined", "namespaces", "are", "preserved", ".", "It", "is", "the", "constructor", "for", "the", "object", "the", "end", "user", "interacts", "with", ".", "As", "indicated", "below", "each", "instance", "has", "full", "custom", "event", "support", "but", "only", "if", "the", "event", "system", "is", "available", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L38-L68
57,652
5long/roil
src/console/simpleyui.js
function(o) { var i, Y = this, core = [], mods = YUI.Env.mods, extras = Y.config.core || [ 'get', 'rls', 'intl-base', 'loader', 'yui-log', 'yui-later', 'yui-throttle' ]; for (i=0; i<extras.length; i++) { if (mods[extras[i]]) { core.push(extras[i]); } } Y._attach(['yui-base']); Y._attach(core); }
javascript
function(o) { var i, Y = this, core = [], mods = YUI.Env.mods, extras = Y.config.core || [ 'get', 'rls', 'intl-base', 'loader', 'yui-log', 'yui-later', 'yui-throttle' ]; for (i=0; i<extras.length; i++) { if (mods[extras[i]]) { core.push(extras[i]); } } Y._attach(['yui-base']); Y._attach(core); }
[ "function", "(", "o", ")", "{", "var", "i", ",", "Y", "=", "this", ",", "core", "=", "[", "]", ",", "mods", "=", "YUI", ".", "Env", ".", "mods", ",", "extras", "=", "Y", ".", "config", ".", "core", "||", "[", "'get'", ",", "'rls'", ",", "'intl-base'", ",", "'loader'", ",", "'yui-log'", ",", "'yui-later'", ",", "'yui-throttle'", "]", ";", "for", "(", "i", "=", "0", ";", "i", "<", "extras", ".", "length", ";", "i", "++", ")", "{", "if", "(", "mods", "[", "extras", "[", "i", "]", "]", ")", "{", "core", ".", "push", "(", "extras", "[", "i", "]", ")", ";", "}", "}", "Y", ".", "_attach", "(", "[", "'yui-base'", "]", ")", ";", "Y", ".", "_attach", "(", "core", ")", ";", "}" ]
Finishes the instance setup. Attaches whatever modules were defined when the yui modules was registered. @method _setup @private
[ "Finishes", "the", "instance", "setup", ".", "Attaches", "whatever", "modules", "were", "defined", "when", "the", "yui", "modules", "was", "registered", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L328-L349
57,653
5long/roil
src/console/simpleyui.js
function(id, method, args) { if (!(method in APPLY_TO_AUTH)) { this.log(method + ': applyTo not allowed', 'warn', 'yui'); return null; } var instance = instances[id], nest, m, i; if (instance) { nest = method.split('.'); m = instance; for (i=0; i<nest.length; i=i+1) { m = m[nest[i]]; if (!m) { this.log('applyTo not found: ' + method, 'warn', 'yui'); } } return m.apply(instance, args); } return null; }
javascript
function(id, method, args) { if (!(method in APPLY_TO_AUTH)) { this.log(method + ': applyTo not allowed', 'warn', 'yui'); return null; } var instance = instances[id], nest, m, i; if (instance) { nest = method.split('.'); m = instance; for (i=0; i<nest.length; i=i+1) { m = m[nest[i]]; if (!m) { this.log('applyTo not found: ' + method, 'warn', 'yui'); } } return m.apply(instance, args); } return null; }
[ "function", "(", "id", ",", "method", ",", "args", ")", "{", "if", "(", "!", "(", "method", "in", "APPLY_TO_AUTH", ")", ")", "{", "this", ".", "log", "(", "method", "+", "': applyTo not allowed'", ",", "'warn'", ",", "'yui'", ")", ";", "return", "null", ";", "}", "var", "instance", "=", "instances", "[", "id", "]", ",", "nest", ",", "m", ",", "i", ";", "if", "(", "instance", ")", "{", "nest", "=", "method", ".", "split", "(", "'.'", ")", ";", "m", "=", "instance", ";", "for", "(", "i", "=", "0", ";", "i", "<", "nest", ".", "length", ";", "i", "=", "i", "+", "1", ")", "{", "m", "=", "m", "[", "nest", "[", "i", "]", "]", ";", "if", "(", "!", "m", ")", "{", "this", ".", "log", "(", "'applyTo not found: '", "+", "method", ",", "'warn'", ",", "'yui'", ")", ";", "}", "}", "return", "m", ".", "apply", "(", "instance", ",", "args", ")", ";", "}", "return", "null", ";", "}" ]
Executes a method on a YUI instance with the specified id if the specified method is whitelisted. @method applyTo @param id {string} the YUI instance id @param method {string} the name of the method to exectute. Ex: 'Object.keys' @param args {Array} the arguments to apply to the method @return {object} the return value from the applied method or null
[ "Executes", "a", "method", "on", "a", "YUI", "instance", "with", "the", "specified", "id", "if", "the", "specified", "method", "is", "whitelisted", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L361-L381
57,654
5long/roil
src/console/simpleyui.js
function(name, fn, version, details) { details = details || {}; var env = YUI.Env, mod = { name: name, fn: fn, version: version, details: details }, loader, i; env.mods[name] = mod; env.versions[version] = env.versions[version] || {}; env.versions[version][name] = mod; for (i in instances) { if (instances.hasOwnProperty(i)) { loader = instances[i].Env._loader; if (loader) { if (!loader.moduleInfo[name]) { loader.addModule(details, name); } } } } return this; }
javascript
function(name, fn, version, details) { details = details || {}; var env = YUI.Env, mod = { name: name, fn: fn, version: version, details: details }, loader, i; env.mods[name] = mod; env.versions[version] = env.versions[version] || {}; env.versions[version][name] = mod; for (i in instances) { if (instances.hasOwnProperty(i)) { loader = instances[i].Env._loader; if (loader) { if (!loader.moduleInfo[name]) { loader.addModule(details, name); } } } } return this; }
[ "function", "(", "name", ",", "fn", ",", "version", ",", "details", ")", "{", "details", "=", "details", "||", "{", "}", ";", "var", "env", "=", "YUI", ".", "Env", ",", "mod", "=", "{", "name", ":", "name", ",", "fn", ":", "fn", ",", "version", ":", "version", ",", "details", ":", "details", "}", ",", "loader", ",", "i", ";", "env", ".", "mods", "[", "name", "]", "=", "mod", ";", "env", ".", "versions", "[", "version", "]", "=", "env", ".", "versions", "[", "version", "]", "||", "{", "}", ";", "env", ".", "versions", "[", "version", "]", "[", "name", "]", "=", "mod", ";", "for", "(", "i", "in", "instances", ")", "{", "if", "(", "instances", ".", "hasOwnProperty", "(", "i", ")", ")", "{", "loader", "=", "instances", "[", "i", "]", ".", "Env", ".", "_loader", ";", "if", "(", "loader", ")", "{", "if", "(", "!", "loader", ".", "moduleInfo", "[", "name", "]", ")", "{", "loader", ".", "addModule", "(", "details", ",", "name", ")", ";", "}", "}", "}", "}", "return", "this", ";", "}" ]
Registers a module with the YUI global. The easiest way to create a first-class YUI module is to use the YUI component build tool. http://yuilibrary.com/projects/builder The build system will produce the YUI.add wrapper for you module, along with any configuration info required for the module. @method add @param name {string} module name @param fn {Function} entry point into the module that is used to bind module to the YUI instance @param version {string} version string @param details optional config data: requires: features that must be present before this module can be attached. optional: optional features that should be present if loadOptional is defined. Note: modules are not often loaded this way in YUI 3, but this field is still useful to inform the user that certain features in the component will require additional dependencies. use: features that are included within this module which need to be be attached automatically when this module is attached. This supports the YUI 3 rollup system -- a module with submodules defined will need to have the submodules listed in the 'use' config. The YUI component build tool does this for you. @return {YUI} the YUI instance
[ "Registers", "a", "module", "with", "the", "YUI", "global", ".", "The", "easiest", "way", "to", "create", "a", "first", "-", "class", "YUI", "module", "is", "to", "use", "the", "YUI", "component", "build", "tool", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L410-L438
57,655
5long/roil
src/console/simpleyui.js
function(r, fromLoader) { var i, name, mod, details, req, use, mods = YUI.Env.mods, Y = this, done = Y.Env._attached, len = r.length; for (i=0; i<len; i++) { name = r[i]; mod = mods[name]; if (!done[name] && mod) { done[name] = true; details = mod.details; req = details.requires; use = details.use; if (req && req.length) { if (!Y._attach(req)) { return false; } } if (mod.fn) { try { mod.fn(Y, name); } catch (e) { Y.error('Attach error: ' + name, e, name); return false; } } if (use && use.length) { if (!Y._attach(use)) { return false; } } } } return true; }
javascript
function(r, fromLoader) { var i, name, mod, details, req, use, mods = YUI.Env.mods, Y = this, done = Y.Env._attached, len = r.length; for (i=0; i<len; i++) { name = r[i]; mod = mods[name]; if (!done[name] && mod) { done[name] = true; details = mod.details; req = details.requires; use = details.use; if (req && req.length) { if (!Y._attach(req)) { return false; } } if (mod.fn) { try { mod.fn(Y, name); } catch (e) { Y.error('Attach error: ' + name, e, name); return false; } } if (use && use.length) { if (!Y._attach(use)) { return false; } } } } return true; }
[ "function", "(", "r", ",", "fromLoader", ")", "{", "var", "i", ",", "name", ",", "mod", ",", "details", ",", "req", ",", "use", ",", "mods", "=", "YUI", ".", "Env", ".", "mods", ",", "Y", "=", "this", ",", "done", "=", "Y", ".", "Env", ".", "_attached", ",", "len", "=", "r", ".", "length", ";", "for", "(", "i", "=", "0", ";", "i", "<", "len", ";", "i", "++", ")", "{", "name", "=", "r", "[", "i", "]", ";", "mod", "=", "mods", "[", "name", "]", ";", "if", "(", "!", "done", "[", "name", "]", "&&", "mod", ")", "{", "done", "[", "name", "]", "=", "true", ";", "details", "=", "mod", ".", "details", ";", "req", "=", "details", ".", "requires", ";", "use", "=", "details", ".", "use", ";", "if", "(", "req", "&&", "req", ".", "length", ")", "{", "if", "(", "!", "Y", ".", "_attach", "(", "req", ")", ")", "{", "return", "false", ";", "}", "}", "if", "(", "mod", ".", "fn", ")", "{", "try", "{", "mod", ".", "fn", "(", "Y", ",", "name", ")", ";", "}", "catch", "(", "e", ")", "{", "Y", ".", "error", "(", "'Attach error: '", "+", "name", ",", "e", ",", "name", ")", ";", "return", "false", ";", "}", "}", "if", "(", "use", "&&", "use", ".", "length", ")", "{", "if", "(", "!", "Y", ".", "_attach", "(", "use", ")", ")", "{", "return", "false", ";", "}", "}", "}", "}", "return", "true", ";", "}" ]
Executes the function associated with each required module, binding the module to the YUI instance. @method _attach @private
[ "Executes", "the", "function", "associated", "with", "each", "required", "module", "binding", "the", "module", "to", "the", "YUI", "instance", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L446-L488
57,656
5long/roil
src/console/simpleyui.js
function(msg, e) { var Y = this, ret; if (Y.config.errorFn) { ret = Y.config.errorFn.apply(Y, arguments); } if (Y.config.throwFail && !ret) { throw (e || new Error(msg)); } else { Y.message(msg, "error"); // don't scrub this one } return Y; }
javascript
function(msg, e) { var Y = this, ret; if (Y.config.errorFn) { ret = Y.config.errorFn.apply(Y, arguments); } if (Y.config.throwFail && !ret) { throw (e || new Error(msg)); } else { Y.message(msg, "error"); // don't scrub this one } return Y; }
[ "function", "(", "msg", ",", "e", ")", "{", "var", "Y", "=", "this", ",", "ret", ";", "if", "(", "Y", ".", "config", ".", "errorFn", ")", "{", "ret", "=", "Y", ".", "config", ".", "errorFn", ".", "apply", "(", "Y", ",", "arguments", ")", ";", "}", "if", "(", "Y", ".", "config", ".", "throwFail", "&&", "!", "ret", ")", "{", "throw", "(", "e", "||", "new", "Error", "(", "msg", ")", ")", ";", "}", "else", "{", "Y", ".", "message", "(", "msg", ",", "\"error\"", ")", ";", "// don't scrub this one", "}", "return", "Y", ";", "}" ]
Report an error. The reporting mechanism is controled by the 'throwFail' configuration attribute. If throwFail is not specified, the message is written to the Logger, otherwise a JS error is thrown @method error @param msg {string} the error message @param e {Error} Optional JS error that was caught. If supplied and throwFail is specified, this error will be re-thrown. @return {YUI} this YUI instance
[ "Report", "an", "error", ".", "The", "reporting", "mechanism", "is", "controled", "by", "the", "throwFail", "configuration", "attribute", ".", "If", "throwFail", "is", "not", "specified", "the", "message", "is", "written", "to", "the", "Logger", "otherwise", "a", "JS", "error", "is", "thrown" ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L817-L832
57,657
5long/roil
src/console/simpleyui.js
function(pre) { var id = this.Env._guidp + (++this.Env._uidx); return (pre) ? (pre + id) : id; }
javascript
function(pre) { var id = this.Env._guidp + (++this.Env._uidx); return (pre) ? (pre + id) : id; }
[ "function", "(", "pre", ")", "{", "var", "id", "=", "this", ".", "Env", ".", "_guidp", "+", "(", "++", "this", ".", "Env", ".", "_uidx", ")", ";", "return", "(", "pre", ")", "?", "(", "pre", "+", "id", ")", ":", "id", ";", "}" ]
Generate an id that is unique among all YUI instances @method guid @param pre {string} optional guid prefix @return {string} the guid
[ "Generate", "an", "id", "that", "is", "unique", "among", "all", "YUI", "instances" ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L840-L843
57,658
5long/roil
src/console/simpleyui.js
function(o, readOnly) { var uid; if (!o) { return o; } // IE generates its own unique ID for dom nodes // The uniqueID property of a document node returns a new ID if (o.uniqueID && o.nodeType && o.nodeType !== 9) { uid = o.uniqueID; } else { uid = (typeof o === 'string') ? o : o._yuid; } if (!uid) { uid = this.guid(); if (!readOnly) { try { o._yuid = uid; } catch(e) { uid = null; } } } return uid; }
javascript
function(o, readOnly) { var uid; if (!o) { return o; } // IE generates its own unique ID for dom nodes // The uniqueID property of a document node returns a new ID if (o.uniqueID && o.nodeType && o.nodeType !== 9) { uid = o.uniqueID; } else { uid = (typeof o === 'string') ? o : o._yuid; } if (!uid) { uid = this.guid(); if (!readOnly) { try { o._yuid = uid; } catch(e) { uid = null; } } } return uid; }
[ "function", "(", "o", ",", "readOnly", ")", "{", "var", "uid", ";", "if", "(", "!", "o", ")", "{", "return", "o", ";", "}", "// IE generates its own unique ID for dom nodes", "// The uniqueID property of a document node returns a new ID", "if", "(", "o", ".", "uniqueID", "&&", "o", ".", "nodeType", "&&", "o", ".", "nodeType", "!==", "9", ")", "{", "uid", "=", "o", ".", "uniqueID", ";", "}", "else", "{", "uid", "=", "(", "typeof", "o", "===", "'string'", ")", "?", "o", ":", "o", ".", "_yuid", ";", "}", "if", "(", "!", "uid", ")", "{", "uid", "=", "this", ".", "guid", "(", ")", ";", "if", "(", "!", "readOnly", ")", "{", "try", "{", "o", ".", "_yuid", "=", "uid", ";", "}", "catch", "(", "e", ")", "{", "uid", "=", "null", ";", "}", "}", "}", "return", "uid", ";", "}" ]
Returns a guid associated with an object. If the object does not have one, a new one is created unless readOnly is specified. @method stamp @param o The object to stamp @param readOnly {boolean} if true, a valid guid will only be returned if the object has one assigned to it. @return {string} The object's guid or null
[ "Returns", "a", "guid", "associated", "with", "an", "object", ".", "If", "the", "object", "does", "not", "have", "one", "a", "new", "one", "is", "created", "unless", "readOnly", "is", "specified", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L855-L880
57,659
5long/roil
src/console/simpleyui.js
function () { Y.Array.each(Y.Array(arguments,0,true),function (fn) { this._q.push(fn); },this); return this; }
javascript
function () { Y.Array.each(Y.Array(arguments,0,true),function (fn) { this._q.push(fn); },this); return this; }
[ "function", "(", ")", "{", "Y", ".", "Array", ".", "each", "(", "Y", ".", "Array", "(", "arguments", ",", "0", ",", "true", ")", ",", "function", "(", "fn", ")", "{", "this", ".", "_q", ".", "push", "(", "fn", ")", ";", "}", ",", "this", ")", ";", "return", "this", ";", "}" ]
Add 0..n items to the end of the queue @method add @param item* {MIXED} 0..n items
[ "Add", "0", "..", "n", "items", "to", "the", "end", "of", "the", "queue" ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L1900-L1906
57,660
5long/roil
src/console/simpleyui.js
function(o) { var id = (L.isString(o)) ? o : o.tId, q = queues[id]; if (q) { q.aborted = true; } }
javascript
function(o) { var id = (L.isString(o)) ? o : o.tId, q = queues[id]; if (q) { q.aborted = true; } }
[ "function", "(", "o", ")", "{", "var", "id", "=", "(", "L", ".", "isString", "(", "o", ")", ")", "?", "o", ":", "o", ".", "tId", ",", "q", "=", "queues", "[", "id", "]", ";", "if", "(", "q", ")", "{", "q", ".", "aborted", "=", "true", ";", "}", "}" ]
Abort a transaction @method abort @static @param o {string|object} Either the tId or the object returned from script() or css()
[ "Abort", "a", "transaction" ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L3177-L3183
57,661
5long/roil
src/console/simpleyui.js
function (preferredLanguages, availableLanguages) { var i, language, result, index; // check whether the list of available languages contains language; if so return it function scan(language) { var i; for (i = 0; i < availableLanguages.length; i += 1) { if (language.toLowerCase() === availableLanguages[i].toLowerCase()) { return availableLanguages[i]; } } } if (Y.Lang.isString(preferredLanguages)) { preferredLanguages = preferredLanguages.split(SPLIT_REGEX); } for (i = 0; i < preferredLanguages.length; i += 1) { language = preferredLanguages[i]; if (!language || language === "*") { continue; } // check the fallback sequence for one language while (language.length > 0) { result = scan(language); if (result) { return result; } else { index = language.lastIndexOf("-"); if (index >= 0) { language = language.substring(0, index); // one-character subtags get cut along with the following subtag if (index >= 2 && language.charAt(index - 2) === "-") { language = language.substring(0, index - 2); } } else { // nothing available for this language break; } } } } return ""; }
javascript
function (preferredLanguages, availableLanguages) { var i, language, result, index; // check whether the list of available languages contains language; if so return it function scan(language) { var i; for (i = 0; i < availableLanguages.length; i += 1) { if (language.toLowerCase() === availableLanguages[i].toLowerCase()) { return availableLanguages[i]; } } } if (Y.Lang.isString(preferredLanguages)) { preferredLanguages = preferredLanguages.split(SPLIT_REGEX); } for (i = 0; i < preferredLanguages.length; i += 1) { language = preferredLanguages[i]; if (!language || language === "*") { continue; } // check the fallback sequence for one language while (language.length > 0) { result = scan(language); if (result) { return result; } else { index = language.lastIndexOf("-"); if (index >= 0) { language = language.substring(0, index); // one-character subtags get cut along with the following subtag if (index >= 2 && language.charAt(index - 2) === "-") { language = language.substring(0, index - 2); } } else { // nothing available for this language break; } } } } return ""; }
[ "function", "(", "preferredLanguages", ",", "availableLanguages", ")", "{", "var", "i", ",", "language", ",", "result", ",", "index", ";", "// check whether the list of available languages contains language; if so return it", "function", "scan", "(", "language", ")", "{", "var", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "availableLanguages", ".", "length", ";", "i", "+=", "1", ")", "{", "if", "(", "language", ".", "toLowerCase", "(", ")", "===", "availableLanguages", "[", "i", "]", ".", "toLowerCase", "(", ")", ")", "{", "return", "availableLanguages", "[", "i", "]", ";", "}", "}", "}", "if", "(", "Y", ".", "Lang", ".", "isString", "(", "preferredLanguages", ")", ")", "{", "preferredLanguages", "=", "preferredLanguages", ".", "split", "(", "SPLIT_REGEX", ")", ";", "}", "for", "(", "i", "=", "0", ";", "i", "<", "preferredLanguages", ".", "length", ";", "i", "+=", "1", ")", "{", "language", "=", "preferredLanguages", "[", "i", "]", ";", "if", "(", "!", "language", "||", "language", "===", "\"*\"", ")", "{", "continue", ";", "}", "// check the fallback sequence for one language", "while", "(", "language", ".", "length", ">", "0", ")", "{", "result", "=", "scan", "(", "language", ")", ";", "if", "(", "result", ")", "{", "return", "result", ";", "}", "else", "{", "index", "=", "language", ".", "lastIndexOf", "(", "\"-\"", ")", ";", "if", "(", "index", ">=", "0", ")", "{", "language", "=", "language", ".", "substring", "(", "0", ",", "index", ")", ";", "// one-character subtags get cut along with the following subtag", "if", "(", "index", ">=", "2", "&&", "language", ".", "charAt", "(", "index", "-", "2", ")", "===", "\"-\"", ")", "{", "language", "=", "language", ".", "substring", "(", "0", ",", "index", "-", "2", ")", ";", "}", "}", "else", "{", "// nothing available for this language", "break", ";", "}", "}", "}", "}", "return", "\"\"", ";", "}" ]
Returns the language among those available that best matches the preferred language list, using the Lookup algorithm of BCP 47. If none of the available languages meets the user's preferences, then "" is returned. Extended language ranges are not supported. @method lookupBestLang @param {String[] | String} preferredLanguages The list of preferred languages in descending preference order, represented as BCP 47 language tags. A string array or a comma-separated list. @param {String[]} availableLanguages The list of languages that the application supports, represented as BCP 47 language tags. @return {String} The available language that best matches the preferred language list, or "". @since 3.1.0
[ "Returns", "the", "language", "among", "those", "available", "that", "best", "matches", "the", "preferred", "language", "list", "using", "the", "Lookup", "algorithm", "of", "BCP", "47", ".", "If", "none", "of", "the", "available", "languages", "meets", "the", "user", "s", "preferences", "then", "is", "returned", ".", "Extended", "language", "ranges", "are", "not", "supported", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L3554-L3599
57,662
5long/roil
src/console/simpleyui.js
scan
function scan(language) { var i; for (i = 0; i < availableLanguages.length; i += 1) { if (language.toLowerCase() === availableLanguages[i].toLowerCase()) { return availableLanguages[i]; } } }
javascript
function scan(language) { var i; for (i = 0; i < availableLanguages.length; i += 1) { if (language.toLowerCase() === availableLanguages[i].toLowerCase()) { return availableLanguages[i]; } } }
[ "function", "scan", "(", "language", ")", "{", "var", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "availableLanguages", ".", "length", ";", "i", "+=", "1", ")", "{", "if", "(", "language", ".", "toLowerCase", "(", ")", "===", "availableLanguages", "[", "i", "]", ".", "toLowerCase", "(", ")", ")", "{", "return", "availableLanguages", "[", "i", "]", ";", "}", "}", "}" ]
check whether the list of available languages contains language; if so return it
[ "check", "whether", "the", "list", "of", "available", "languages", "contains", "language", ";", "if", "so", "return", "it" ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L3559-L3566
57,663
5long/roil
src/console/simpleyui.js
function(o, f, c, proto, action) { if (o && o[action] && o !== Y) { return o[action].call(o, f, c); } else { switch (A.test(o)) { case 1: return A[action](o, f, c); case 2: return A[action](Y.Array(o, 0, true), f, c); default: return Y.Object[action](o, f, c, proto); } } }
javascript
function(o, f, c, proto, action) { if (o && o[action] && o !== Y) { return o[action].call(o, f, c); } else { switch (A.test(o)) { case 1: return A[action](o, f, c); case 2: return A[action](Y.Array(o, 0, true), f, c); default: return Y.Object[action](o, f, c, proto); } } }
[ "function", "(", "o", ",", "f", ",", "c", ",", "proto", ",", "action", ")", "{", "if", "(", "o", "&&", "o", "[", "action", "]", "&&", "o", "!==", "Y", ")", "{", "return", "o", "[", "action", "]", ".", "call", "(", "o", ",", "f", ",", "c", ")", ";", "}", "else", "{", "switch", "(", "A", ".", "test", "(", "o", ")", ")", "{", "case", "1", ":", "return", "A", "[", "action", "]", "(", "o", ",", "f", ",", "c", ")", ";", "case", "2", ":", "return", "A", "[", "action", "]", "(", "Y", ".", "Array", "(", "o", ",", "0", ",", "true", ")", ",", "f", ",", "c", ")", ";", "default", ":", "return", "Y", ".", "Object", "[", "action", "]", "(", "o", ",", "f", ",", "c", ",", "proto", ")", ";", "}", "}", "}" ]
Supplies object inheritance and manipulation utilities. This adds additional functionaity to what is provided in yui-base, and the methods are applied directly to the YUI instance. This module is required for most YUI components. @module oop
[ "Supplies", "object", "inheritance", "and", "manipulation", "utilities", ".", "This", "adds", "additional", "functionaity", "to", "what", "is", "provided", "in", "yui", "-", "base", "and", "the", "methods", "are", "applied", "directly", "to", "the", "YUI", "instance", ".", "This", "module", "is", "required", "for", "most", "YUI", "components", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L3852-L3865
57,664
5long/roil
src/console/simpleyui.js
function(element, axis, fn, all) { while (element && (element = element[axis])) { // NOTE: assignment if ( (all || element[TAG_NAME]) && (!fn || fn(element)) ) { return element; } } return null; }
javascript
function(element, axis, fn, all) { while (element && (element = element[axis])) { // NOTE: assignment if ( (all || element[TAG_NAME]) && (!fn || fn(element)) ) { return element; } } return null; }
[ "function", "(", "element", ",", "axis", ",", "fn", ",", "all", ")", "{", "while", "(", "element", "&&", "(", "element", "=", "element", "[", "axis", "]", ")", ")", "{", "// NOTE: assignment", "if", "(", "(", "all", "||", "element", "[", "TAG_NAME", "]", ")", "&&", "(", "!", "fn", "||", "fn", "(", "element", ")", ")", ")", "{", "return", "element", ";", "}", "}", "return", "null", ";", "}" ]
Searches the element by the given axis for the first matching element. @method elementByAxis @param {HTMLElement} element The html element. @param {String} axis The axis to search (parentNode, nextSibling, previousSibling). @param {Function} fn optional An optional boolean test to apply. @param {Boolean} all optional Whether all node types should be returned, or just element nodes. The optional function is passed the current HTMLElement being tested as its only argument. If no function is given, the first element is returned. @return {HTMLElement | null} The matching element or null if none found.
[ "Searches", "the", "element", "by", "the", "given", "axis", "for", "the", "first", "matching", "element", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L4362-L4369
57,665
5long/roil
src/console/simpleyui.js
function(element, needle) { var ret = false; if ( !needle || !element || !needle[NODE_TYPE] || !element[NODE_TYPE]) { ret = false; } else if (element[CONTAINS]) { if (Y.UA.opera || needle[NODE_TYPE] === 1) { // IE & SAF contains fail if needle not an ELEMENT_NODE ret = element[CONTAINS](needle); } else { ret = Y.DOM._bruteContains(element, needle); } } else if (element[COMPARE_DOCUMENT_POSITION]) { // gecko if (element === needle || !!(element[COMPARE_DOCUMENT_POSITION](needle) & 16)) { ret = true; } } return ret; }
javascript
function(element, needle) { var ret = false; if ( !needle || !element || !needle[NODE_TYPE] || !element[NODE_TYPE]) { ret = false; } else if (element[CONTAINS]) { if (Y.UA.opera || needle[NODE_TYPE] === 1) { // IE & SAF contains fail if needle not an ELEMENT_NODE ret = element[CONTAINS](needle); } else { ret = Y.DOM._bruteContains(element, needle); } } else if (element[COMPARE_DOCUMENT_POSITION]) { // gecko if (element === needle || !!(element[COMPARE_DOCUMENT_POSITION](needle) & 16)) { ret = true; } } return ret; }
[ "function", "(", "element", ",", "needle", ")", "{", "var", "ret", "=", "false", ";", "if", "(", "!", "needle", "||", "!", "element", "||", "!", "needle", "[", "NODE_TYPE", "]", "||", "!", "element", "[", "NODE_TYPE", "]", ")", "{", "ret", "=", "false", ";", "}", "else", "if", "(", "element", "[", "CONTAINS", "]", ")", "{", "if", "(", "Y", ".", "UA", ".", "opera", "||", "needle", "[", "NODE_TYPE", "]", "===", "1", ")", "{", "// IE & SAF contains fail if needle not an ELEMENT_NODE", "ret", "=", "element", "[", "CONTAINS", "]", "(", "needle", ")", ";", "}", "else", "{", "ret", "=", "Y", ".", "DOM", ".", "_bruteContains", "(", "element", ",", "needle", ")", ";", "}", "}", "else", "if", "(", "element", "[", "COMPARE_DOCUMENT_POSITION", "]", ")", "{", "// gecko", "if", "(", "element", "===", "needle", "||", "!", "!", "(", "element", "[", "COMPARE_DOCUMENT_POSITION", "]", "(", "needle", ")", "&", "16", ")", ")", "{", "ret", "=", "true", ";", "}", "}", "return", "ret", ";", "}" ]
Determines whether or not one HTMLElement is or contains another HTMLElement. @method contains @param {HTMLElement} element The containing html element. @param {HTMLElement} needle The html element that may be contained. @return {Boolean} Whether or not the element is or contains the needle.
[ "Determines", "whether", "or", "not", "one", "HTMLElement", "is", "or", "contains", "another", "HTMLElement", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L4378-L4396
57,666
5long/roil
src/console/simpleyui.js
function(element, doc) { var ret = false, rootNode; if (element && element.nodeType) { (doc) || (doc = element[OWNER_DOCUMENT]); rootNode = doc[DOCUMENT_ELEMENT]; // contains only works with HTML_ELEMENT if (rootNode && rootNode.contains && element.tagName) { ret = rootNode.contains(element); } else { ret = Y.DOM.contains(rootNode, element); } } return ret; }
javascript
function(element, doc) { var ret = false, rootNode; if (element && element.nodeType) { (doc) || (doc = element[OWNER_DOCUMENT]); rootNode = doc[DOCUMENT_ELEMENT]; // contains only works with HTML_ELEMENT if (rootNode && rootNode.contains && element.tagName) { ret = rootNode.contains(element); } else { ret = Y.DOM.contains(rootNode, element); } } return ret; }
[ "function", "(", "element", ",", "doc", ")", "{", "var", "ret", "=", "false", ",", "rootNode", ";", "if", "(", "element", "&&", "element", ".", "nodeType", ")", "{", "(", "doc", ")", "||", "(", "doc", "=", "element", "[", "OWNER_DOCUMENT", "]", ")", ";", "rootNode", "=", "doc", "[", "DOCUMENT_ELEMENT", "]", ";", "// contains only works with HTML_ELEMENT", "if", "(", "rootNode", "&&", "rootNode", ".", "contains", "&&", "element", ".", "tagName", ")", "{", "ret", "=", "rootNode", ".", "contains", "(", "element", ")", ";", "}", "else", "{", "ret", "=", "Y", ".", "DOM", ".", "contains", "(", "rootNode", ",", "element", ")", ";", "}", "}", "return", "ret", ";", "}" ]
Determines whether or not the HTMLElement is part of the document. @method inDoc @param {HTMLElement} element The containing html element. @param {HTMLElement} doc optional The document to check. @return {Boolean} Whether or not the element is attached to the document.
[ "Determines", "whether", "or", "not", "the", "HTMLElement", "is", "part", "of", "the", "document", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L4405-L4424
57,667
5long/roil
src/console/simpleyui.js
function(html, doc) { if (typeof html === 'string') { html = Y.Lang.trim(html); // match IE which trims whitespace from innerHTML } doc = doc || Y.config.doc; var m = re_tag.exec(html), create = Y.DOM._create, custom = Y.DOM.creators, ret = null, tag, nodes; if (html != undefined) { // not undefined or null if (m && custom[m[1]]) { if (typeof custom[m[1]] === 'function') { create = custom[m[1]]; } else { tag = custom[m[1]]; } } nodes = create(html, doc, tag).childNodes; if (nodes.length === 1) { // return single node, breaking parentNode ref from "fragment" ret = nodes[0].parentNode.removeChild(nodes[0]); } else if (nodes[0] && nodes[0].className === 'yui3-big-dummy') { // using dummy node to preserve some attributes (e.g. OPTION not selected) if (nodes.length === 2) { ret = nodes[0].nextSibling; } else { nodes[0].parentNode.removeChild(nodes[0]); ret = Y.DOM._nl2frag(nodes, doc); } } else { // return multiple nodes as a fragment ret = Y.DOM._nl2frag(nodes, doc); } } return ret; }
javascript
function(html, doc) { if (typeof html === 'string') { html = Y.Lang.trim(html); // match IE which trims whitespace from innerHTML } doc = doc || Y.config.doc; var m = re_tag.exec(html), create = Y.DOM._create, custom = Y.DOM.creators, ret = null, tag, nodes; if (html != undefined) { // not undefined or null if (m && custom[m[1]]) { if (typeof custom[m[1]] === 'function') { create = custom[m[1]]; } else { tag = custom[m[1]]; } } nodes = create(html, doc, tag).childNodes; if (nodes.length === 1) { // return single node, breaking parentNode ref from "fragment" ret = nodes[0].parentNode.removeChild(nodes[0]); } else if (nodes[0] && nodes[0].className === 'yui3-big-dummy') { // using dummy node to preserve some attributes (e.g. OPTION not selected) if (nodes.length === 2) { ret = nodes[0].nextSibling; } else { nodes[0].parentNode.removeChild(nodes[0]); ret = Y.DOM._nl2frag(nodes, doc); } } else { // return multiple nodes as a fragment ret = Y.DOM._nl2frag(nodes, doc); } } return ret; }
[ "function", "(", "html", ",", "doc", ")", "{", "if", "(", "typeof", "html", "===", "'string'", ")", "{", "html", "=", "Y", ".", "Lang", ".", "trim", "(", "html", ")", ";", "// match IE which trims whitespace from innerHTML", "}", "doc", "=", "doc", "||", "Y", ".", "config", ".", "doc", ";", "var", "m", "=", "re_tag", ".", "exec", "(", "html", ")", ",", "create", "=", "Y", ".", "DOM", ".", "_create", ",", "custom", "=", "Y", ".", "DOM", ".", "creators", ",", "ret", "=", "null", ",", "tag", ",", "nodes", ";", "if", "(", "html", "!=", "undefined", ")", "{", "// not undefined or null", "if", "(", "m", "&&", "custom", "[", "m", "[", "1", "]", "]", ")", "{", "if", "(", "typeof", "custom", "[", "m", "[", "1", "]", "]", "===", "'function'", ")", "{", "create", "=", "custom", "[", "m", "[", "1", "]", "]", ";", "}", "else", "{", "tag", "=", "custom", "[", "m", "[", "1", "]", "]", ";", "}", "}", "nodes", "=", "create", "(", "html", ",", "doc", ",", "tag", ")", ".", "childNodes", ";", "if", "(", "nodes", ".", "length", "===", "1", ")", "{", "// return single node, breaking parentNode ref from \"fragment\"", "ret", "=", "nodes", "[", "0", "]", ".", "parentNode", ".", "removeChild", "(", "nodes", "[", "0", "]", ")", ";", "}", "else", "if", "(", "nodes", "[", "0", "]", "&&", "nodes", "[", "0", "]", ".", "className", "===", "'yui3-big-dummy'", ")", "{", "// using dummy node to preserve some attributes (e.g. OPTION not selected)", "if", "(", "nodes", ".", "length", "===", "2", ")", "{", "ret", "=", "nodes", "[", "0", "]", ".", "nextSibling", ";", "}", "else", "{", "nodes", "[", "0", "]", ".", "parentNode", ".", "removeChild", "(", "nodes", "[", "0", "]", ")", ";", "ret", "=", "Y", ".", "DOM", ".", "_nl2frag", "(", "nodes", ",", "doc", ")", ";", "}", "}", "else", "{", "// return multiple nodes as a fragment", "ret", "=", "Y", ".", "DOM", ".", "_nl2frag", "(", "nodes", ",", "doc", ")", ";", "}", "}", "return", "ret", ";", "}" ]
Creates a new dom node using the provided markup string. @method create @param {String} html The markup used to create the element @param {HTMLDocument} doc An optional document context @return {HTMLElement|DocumentFragment} returns a single HTMLElement when creating one node, and a documentFragment when creating multiple nodes.
[ "Creates", "a", "new", "dom", "node", "using", "the", "provided", "markup", "string", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L4465-L4504
57,668
5long/roil
src/console/simpleyui.js
function(node, content, where) { var nodeParent = node.parentNode, newNode; if (content !== undefined && content !== null) { if (content.nodeType) { // domNode newNode = content; } else { // create from string and cache newNode = Y.DOM.create(content); } } if (where) { if (where.nodeType) { // insert regardless of relationship to node // TODO: check if node.contains(where)? where.parentNode.insertBefore(newNode, where); } else { switch (where) { case 'replace': while (node.firstChild) { node.removeChild(node.firstChild); } if (newNode) { // allow empty content to clear node node.appendChild(newNode); } break; case 'before': nodeParent.insertBefore(newNode, node); break; case 'after': if (node.nextSibling) { // IE errors if refNode is null nodeParent.insertBefore(newNode, node.nextSibling); } else { nodeParent.appendChild(newNode); } break; default: node.appendChild(newNode); } } } else { node.appendChild(newNode); } return newNode; }
javascript
function(node, content, where) { var nodeParent = node.parentNode, newNode; if (content !== undefined && content !== null) { if (content.nodeType) { // domNode newNode = content; } else { // create from string and cache newNode = Y.DOM.create(content); } } if (where) { if (where.nodeType) { // insert regardless of relationship to node // TODO: check if node.contains(where)? where.parentNode.insertBefore(newNode, where); } else { switch (where) { case 'replace': while (node.firstChild) { node.removeChild(node.firstChild); } if (newNode) { // allow empty content to clear node node.appendChild(newNode); } break; case 'before': nodeParent.insertBefore(newNode, node); break; case 'after': if (node.nextSibling) { // IE errors if refNode is null nodeParent.insertBefore(newNode, node.nextSibling); } else { nodeParent.appendChild(newNode); } break; default: node.appendChild(newNode); } } } else { node.appendChild(newNode); } return newNode; }
[ "function", "(", "node", ",", "content", ",", "where", ")", "{", "var", "nodeParent", "=", "node", ".", "parentNode", ",", "newNode", ";", "if", "(", "content", "!==", "undefined", "&&", "content", "!==", "null", ")", "{", "if", "(", "content", ".", "nodeType", ")", "{", "// domNode", "newNode", "=", "content", ";", "}", "else", "{", "// create from string and cache", "newNode", "=", "Y", ".", "DOM", ".", "create", "(", "content", ")", ";", "}", "}", "if", "(", "where", ")", "{", "if", "(", "where", ".", "nodeType", ")", "{", "// insert regardless of relationship to node", "// TODO: check if node.contains(where)?", "where", ".", "parentNode", ".", "insertBefore", "(", "newNode", ",", "where", ")", ";", "}", "else", "{", "switch", "(", "where", ")", "{", "case", "'replace'", ":", "while", "(", "node", ".", "firstChild", ")", "{", "node", ".", "removeChild", "(", "node", ".", "firstChild", ")", ";", "}", "if", "(", "newNode", ")", "{", "// allow empty content to clear node", "node", ".", "appendChild", "(", "newNode", ")", ";", "}", "break", ";", "case", "'before'", ":", "nodeParent", ".", "insertBefore", "(", "newNode", ",", "node", ")", ";", "break", ";", "case", "'after'", ":", "if", "(", "node", ".", "nextSibling", ")", "{", "// IE errors if refNode is null", "nodeParent", ".", "insertBefore", "(", "newNode", ",", "node", ".", "nextSibling", ")", ";", "}", "else", "{", "nodeParent", ".", "appendChild", "(", "newNode", ")", ";", "}", "break", ";", "default", ":", "node", ".", "appendChild", "(", "newNode", ")", ";", "}", "}", "}", "else", "{", "node", ".", "appendChild", "(", "newNode", ")", ";", "}", "return", "newNode", ";", "}" ]
Inserts content in a node at the given location @method addHTML @param {HTMLElement} node The node to insert into @param {String | HTMLElement} content The content to be inserted @param {String | HTMLElement} where Where to insert the content If no "where" is given, content is appended to the node Possible values for "where" <dl> <dt>HTMLElement</dt> <dd>The element to insert before</dd> <dt>"replace"</dt> <dd>Replaces the existing HTML</dd> <dt>"before"</dt> <dd>Inserts before the existing HTML</dd> <dt>"before"</dt> <dd>Inserts content before the node</dd> <dt>"after"</dt> <dd>Inserts content after the node</dd> </dl>
[ "Inserts", "content", "in", "a", "node", "at", "the", "given", "location" ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L4616-L4661
57,669
5long/roil
src/console/simpleyui.js
function(element) { var doc = Y.DOM._getDoc(element); return doc[DEFAULT_VIEW] || doc[PARENT_WINDOW] || Y.config.win; }
javascript
function(element) { var doc = Y.DOM._getDoc(element); return doc[DEFAULT_VIEW] || doc[PARENT_WINDOW] || Y.config.win; }
[ "function", "(", "element", ")", "{", "var", "doc", "=", "Y", ".", "DOM", ".", "_getDoc", "(", "element", ")", ";", "return", "doc", "[", "DEFAULT_VIEW", "]", "||", "doc", "[", "PARENT_WINDOW", "]", "||", "Y", ".", "config", ".", "win", ";", "}" ]
returns the appropriate window. @method _getWin @private @param {HTMLElement} element optional Target element. @return {Object} The window for the given element or the default window.
[ "returns", "the", "appropriate", "window", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L4788-L4791
57,670
5long/roil
src/console/simpleyui.js
function(node, className) { var re = Y.DOM._getRegExp('(?:^|\\s+)' + className + '(?:\\s+|$)'); return re.test(node.className); }
javascript
function(node, className) { var re = Y.DOM._getRegExp('(?:^|\\s+)' + className + '(?:\\s+|$)'); return re.test(node.className); }
[ "function", "(", "node", ",", "className", ")", "{", "var", "re", "=", "Y", ".", "DOM", ".", "_getRegExp", "(", "'(?:^|\\\\s+)'", "+", "className", "+", "'(?:\\\\s+|$)'", ")", ";", "return", "re", ".", "test", "(", "node", ".", "className", ")", ";", "}" ]
Determines whether a DOM element has the given className. @method hasClass @for DOM @param {HTMLElement} element The DOM element. @param {String} className the class name to search for @return {Boolean} Whether or not the element has the given class.
[ "Determines", "whether", "a", "DOM", "element", "has", "the", "given", "className", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L4948-L4951
57,671
5long/roil
src/console/simpleyui.js
function(node, className) { if (!Y.DOM.hasClass(node, className)) { // skip if already present node.className = Y.Lang.trim([node.className, className].join(' ')); } }
javascript
function(node, className) { if (!Y.DOM.hasClass(node, className)) { // skip if already present node.className = Y.Lang.trim([node.className, className].join(' ')); } }
[ "function", "(", "node", ",", "className", ")", "{", "if", "(", "!", "Y", ".", "DOM", ".", "hasClass", "(", "node", ",", "className", ")", ")", "{", "// skip if already present ", "node", ".", "className", "=", "Y", ".", "Lang", ".", "trim", "(", "[", "node", ".", "className", ",", "className", "]", ".", "join", "(", "' '", ")", ")", ";", "}", "}" ]
Adds a class name to a given DOM element. @method addClass @for DOM @param {HTMLElement} element The DOM element. @param {String} className the class name to add to the class attribute
[ "Adds", "a", "class", "name", "to", "a", "given", "DOM", "element", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L4960-L4964
57,672
5long/roil
src/console/simpleyui.js
function(node, className) { if (className && hasClass(node, className)) { node.className = Y.Lang.trim(node.className.replace(Y.DOM._getRegExp('(?:^|\\s+)' + className + '(?:\\s+|$)'), ' ')); if ( hasClass(node, className) ) { // in case of multiple adjacent removeClass(node, className); } } }
javascript
function(node, className) { if (className && hasClass(node, className)) { node.className = Y.Lang.trim(node.className.replace(Y.DOM._getRegExp('(?:^|\\s+)' + className + '(?:\\s+|$)'), ' ')); if ( hasClass(node, className) ) { // in case of multiple adjacent removeClass(node, className); } } }
[ "function", "(", "node", ",", "className", ")", "{", "if", "(", "className", "&&", "hasClass", "(", "node", ",", "className", ")", ")", "{", "node", ".", "className", "=", "Y", ".", "Lang", ".", "trim", "(", "node", ".", "className", ".", "replace", "(", "Y", ".", "DOM", ".", "_getRegExp", "(", "'(?:^|\\\\s+)'", "+", "className", "+", "'(?:\\\\s+|$)'", ")", ",", "' '", ")", ")", ";", "if", "(", "hasClass", "(", "node", ",", "className", ")", ")", "{", "// in case of multiple adjacent", "removeClass", "(", "node", ",", "className", ")", ";", "}", "}", "}" ]
Removes a class name from a given element. @method removeClass @for DOM @param {HTMLElement} element The DOM element. @param {String} className the class name to remove from the class attribute
[ "Removes", "a", "class", "name", "from", "a", "given", "element", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L4973-L4982
57,673
5long/roil
src/console/simpleyui.js
function(node, className, force) { var add = (force !== undefined) ? force : !(hasClass(node, className)); if (add) { addClass(node, className); } else { removeClass(node, className); } }
javascript
function(node, className, force) { var add = (force !== undefined) ? force : !(hasClass(node, className)); if (add) { addClass(node, className); } else { removeClass(node, className); } }
[ "function", "(", "node", ",", "className", ",", "force", ")", "{", "var", "add", "=", "(", "force", "!==", "undefined", ")", "?", "force", ":", "!", "(", "hasClass", "(", "node", ",", "className", ")", ")", ";", "if", "(", "add", ")", "{", "addClass", "(", "node", ",", "className", ")", ";", "}", "else", "{", "removeClass", "(", "node", ",", "className", ")", ";", "}", "}" ]
If the className exists on the node it is removed, if it doesn't exist it is added. @method toggleClass @for DOM @param {HTMLElement} element The DOM element @param {String} className the class name to be toggled @param {Boolean} addClass optional boolean to indicate whether class should be added or removed regardless of current state
[ "If", "the", "className", "exists", "on", "the", "node", "it", "is", "removed", "if", "it", "doesn", "t", "exist", "it", "is", "added", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L5007-L5016
57,674
5long/roil
src/console/simpleyui.js
function(node, att, val, style) { style = style || node.style; var CUSTOM_STYLES = Y_DOM.CUSTOM_STYLES, current; if (style) { if (val === null || val === '') { // normalize unsetting val = ''; } else if (!isNaN(new Number(val)) && re_unit.test(att)) { // number values may need a unit val += Y_DOM.DEFAULT_UNIT; } if (att in CUSTOM_STYLES) { if (CUSTOM_STYLES[att].set) { CUSTOM_STYLES[att].set(node, val, style); return; // NOTE: return } else if (typeof CUSTOM_STYLES[att] === 'string') { att = CUSTOM_STYLES[att]; } } style[att] = val; } }
javascript
function(node, att, val, style) { style = style || node.style; var CUSTOM_STYLES = Y_DOM.CUSTOM_STYLES, current; if (style) { if (val === null || val === '') { // normalize unsetting val = ''; } else if (!isNaN(new Number(val)) && re_unit.test(att)) { // number values may need a unit val += Y_DOM.DEFAULT_UNIT; } if (att in CUSTOM_STYLES) { if (CUSTOM_STYLES[att].set) { CUSTOM_STYLES[att].set(node, val, style); return; // NOTE: return } else if (typeof CUSTOM_STYLES[att] === 'string') { att = CUSTOM_STYLES[att]; } } style[att] = val; } }
[ "function", "(", "node", ",", "att", ",", "val", ",", "style", ")", "{", "style", "=", "style", "||", "node", ".", "style", ";", "var", "CUSTOM_STYLES", "=", "Y_DOM", ".", "CUSTOM_STYLES", ",", "current", ";", "if", "(", "style", ")", "{", "if", "(", "val", "===", "null", "||", "val", "===", "''", ")", "{", "// normalize unsetting", "val", "=", "''", ";", "}", "else", "if", "(", "!", "isNaN", "(", "new", "Number", "(", "val", ")", ")", "&&", "re_unit", ".", "test", "(", "att", ")", ")", "{", "// number values may need a unit", "val", "+=", "Y_DOM", ".", "DEFAULT_UNIT", ";", "}", "if", "(", "att", "in", "CUSTOM_STYLES", ")", "{", "if", "(", "CUSTOM_STYLES", "[", "att", "]", ".", "set", ")", "{", "CUSTOM_STYLES", "[", "att", "]", ".", "set", "(", "node", ",", "val", ",", "style", ")", ";", "return", ";", "// NOTE: return", "}", "else", "if", "(", "typeof", "CUSTOM_STYLES", "[", "att", "]", "===", "'string'", ")", "{", "att", "=", "CUSTOM_STYLES", "[", "att", "]", ";", "}", "}", "style", "[", "att", "]", "=", "val", ";", "}", "}" ]
Sets a style property for a given element. @method setStyle @param {HTMLElement} An HTMLElement to apply the style to. @param {String} att The style property to set. @param {String|Number} val The value.
[ "Sets", "a", "style", "property", "for", "a", "given", "element", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L5126-L5148
57,675
5long/roil
src/console/simpleyui.js
function(node, att, style) { style = style || node.style; var CUSTOM_STYLES = Y_DOM.CUSTOM_STYLES, val = ''; if (style) { if (att in CUSTOM_STYLES) { if (CUSTOM_STYLES[att].get) { return CUSTOM_STYLES[att].get(node, att, style); // NOTE: return } else if (typeof CUSTOM_STYLES[att] === 'string') { att = CUSTOM_STYLES[att]; } } val = style[att]; if (val === '') { // TODO: is empty string sufficient? val = Y_DOM[GET_COMPUTED_STYLE](node, att); } } return val; }
javascript
function(node, att, style) { style = style || node.style; var CUSTOM_STYLES = Y_DOM.CUSTOM_STYLES, val = ''; if (style) { if (att in CUSTOM_STYLES) { if (CUSTOM_STYLES[att].get) { return CUSTOM_STYLES[att].get(node, att, style); // NOTE: return } else if (typeof CUSTOM_STYLES[att] === 'string') { att = CUSTOM_STYLES[att]; } } val = style[att]; if (val === '') { // TODO: is empty string sufficient? val = Y_DOM[GET_COMPUTED_STYLE](node, att); } } return val; }
[ "function", "(", "node", ",", "att", ",", "style", ")", "{", "style", "=", "style", "||", "node", ".", "style", ";", "var", "CUSTOM_STYLES", "=", "Y_DOM", ".", "CUSTOM_STYLES", ",", "val", "=", "''", ";", "if", "(", "style", ")", "{", "if", "(", "att", "in", "CUSTOM_STYLES", ")", "{", "if", "(", "CUSTOM_STYLES", "[", "att", "]", ".", "get", ")", "{", "return", "CUSTOM_STYLES", "[", "att", "]", ".", "get", "(", "node", ",", "att", ",", "style", ")", ";", "// NOTE: return", "}", "else", "if", "(", "typeof", "CUSTOM_STYLES", "[", "att", "]", "===", "'string'", ")", "{", "att", "=", "CUSTOM_STYLES", "[", "att", "]", ";", "}", "}", "val", "=", "style", "[", "att", "]", ";", "if", "(", "val", "===", "''", ")", "{", "// TODO: is empty string sufficient?", "val", "=", "Y_DOM", "[", "GET_COMPUTED_STYLE", "]", "(", "node", ",", "att", ")", ";", "}", "}", "return", "val", ";", "}" ]
Returns the current style value for the given property. @method getStyle @param {HTMLElement} An HTMLElement to get the style from. @param {String} att The style property to get.
[ "Returns", "the", "current", "style", "value", "for", "the", "given", "property", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L5156-L5176
57,676
5long/roil
src/console/simpleyui.js
function(node, hash) { var style = node.style; Y.each(hash, function(v, n) { Y_DOM.setStyle(node, n, v, style); }, Y_DOM); }
javascript
function(node, hash) { var style = node.style; Y.each(hash, function(v, n) { Y_DOM.setStyle(node, n, v, style); }, Y_DOM); }
[ "function", "(", "node", ",", "hash", ")", "{", "var", "style", "=", "node", ".", "style", ";", "Y", ".", "each", "(", "hash", ",", "function", "(", "v", ",", "n", ")", "{", "Y_DOM", ".", "setStyle", "(", "node", ",", "n", ",", "v", ",", "style", ")", ";", "}", ",", "Y_DOM", ")", ";", "}" ]
Sets multiple style properties. @method setStyles @param {HTMLElement} node An HTMLElement to apply the styles to. @param {Object} hash An object literal of property:value pairs.
[ "Sets", "multiple", "style", "properties", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L5184-L5189
57,677
5long/roil
src/console/simpleyui.js
function(node, att) { var val = '', doc = node[OWNER_DOCUMENT]; if (node[STYLE]) { val = doc[DEFAULT_VIEW][GET_COMPUTED_STYLE](node, null)[att]; } return val; }
javascript
function(node, att) { var val = '', doc = node[OWNER_DOCUMENT]; if (node[STYLE]) { val = doc[DEFAULT_VIEW][GET_COMPUTED_STYLE](node, null)[att]; } return val; }
[ "function", "(", "node", ",", "att", ")", "{", "var", "val", "=", "''", ",", "doc", "=", "node", "[", "OWNER_DOCUMENT", "]", ";", "if", "(", "node", "[", "STYLE", "]", ")", "{", "val", "=", "doc", "[", "DEFAULT_VIEW", "]", "[", "GET_COMPUTED_STYLE", "]", "(", "node", ",", "null", ")", "[", "att", "]", ";", "}", "return", "val", ";", "}" ]
Returns the computed style for the given node. @method getComputedStyle @param {HTMLElement} An HTMLElement to get the style from. @param {String} att The style property to get. @return {String} The computed value of the style property.
[ "Returns", "the", "computed", "style", "for", "the", "given", "node", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L5198-L5206
57,678
5long/roil
src/console/simpleyui.js
function(node, doc) { doc = doc || (node) ? Y_DOM._getDoc(node) : Y.config.doc; // perf optimization var dv = doc.defaultView, pageOffset = (dv) ? dv.pageXOffset : 0; return Math.max(doc[DOCUMENT_ELEMENT].scrollLeft, doc.body.scrollLeft, pageOffset); }
javascript
function(node, doc) { doc = doc || (node) ? Y_DOM._getDoc(node) : Y.config.doc; // perf optimization var dv = doc.defaultView, pageOffset = (dv) ? dv.pageXOffset : 0; return Math.max(doc[DOCUMENT_ELEMENT].scrollLeft, doc.body.scrollLeft, pageOffset); }
[ "function", "(", "node", ",", "doc", ")", "{", "doc", "=", "doc", "||", "(", "node", ")", "?", "Y_DOM", ".", "_getDoc", "(", "node", ")", ":", "Y", ".", "config", ".", "doc", ";", "// perf optimization", "var", "dv", "=", "doc", ".", "defaultView", ",", "pageOffset", "=", "(", "dv", ")", "?", "dv", ".", "pageXOffset", ":", "0", ";", "return", "Math", ".", "max", "(", "doc", "[", "DOCUMENT_ELEMENT", "]", ".", "scrollLeft", ",", "doc", ".", "body", ".", "scrollLeft", ",", "pageOffset", ")", ";", "}" ]
Amount page has been scroll horizontally @method docScrollX @return {Number} The current amount the screen is scrolled horizontally.
[ "Amount", "page", "has", "been", "scroll", "horizontally" ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L5475-L5480
57,679
5long/roil
src/console/simpleyui.js
function(node, doc) { doc = doc || (node) ? Y_DOM._getDoc(node) : Y.config.doc; // perf optimization var dv = doc.defaultView, pageOffset = (dv) ? dv.pageYOffset : 0; return Math.max(doc[DOCUMENT_ELEMENT].scrollTop, doc.body.scrollTop, pageOffset); }
javascript
function(node, doc) { doc = doc || (node) ? Y_DOM._getDoc(node) : Y.config.doc; // perf optimization var dv = doc.defaultView, pageOffset = (dv) ? dv.pageYOffset : 0; return Math.max(doc[DOCUMENT_ELEMENT].scrollTop, doc.body.scrollTop, pageOffset); }
[ "function", "(", "node", ",", "doc", ")", "{", "doc", "=", "doc", "||", "(", "node", ")", "?", "Y_DOM", ".", "_getDoc", "(", "node", ")", ":", "Y", ".", "config", ".", "doc", ";", "// perf optimization", "var", "dv", "=", "doc", ".", "defaultView", ",", "pageOffset", "=", "(", "dv", ")", "?", "dv", ".", "pageYOffset", ":", "0", ";", "return", "Math", ".", "max", "(", "doc", "[", "DOCUMENT_ELEMENT", "]", ".", "scrollTop", ",", "doc", ".", "body", ".", "scrollTop", ",", "pageOffset", ")", ";", "}" ]
Amount page has been scroll vertically @method docScrollY @return {Number} The current amount the screen is scrolled vertically.
[ "Amount", "page", "has", "been", "scroll", "vertically" ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L5487-L5492
57,680
5long/roil
src/console/simpleyui.js
function(node, node2, altRegion) { var r = altRegion || DOM.region(node), region = {}, n = node2, off; if (n.tagName) { region = DOM.region(n); } else if (Y.Lang.isObject(node2)) { region = node2; } else { return false; } off = getOffsets(region, r); return { top: off[TOP], right: off[RIGHT], bottom: off[BOTTOM], left: off[LEFT], area: ((off[BOTTOM] - off[TOP]) * (off[RIGHT] - off[LEFT])), yoff: ((off[BOTTOM] - off[TOP])), xoff: (off[RIGHT] - off[LEFT]), inRegion: DOM.inRegion(node, node2, false, altRegion) }; }
javascript
function(node, node2, altRegion) { var r = altRegion || DOM.region(node), region = {}, n = node2, off; if (n.tagName) { region = DOM.region(n); } else if (Y.Lang.isObject(node2)) { region = node2; } else { return false; } off = getOffsets(region, r); return { top: off[TOP], right: off[RIGHT], bottom: off[BOTTOM], left: off[LEFT], area: ((off[BOTTOM] - off[TOP]) * (off[RIGHT] - off[LEFT])), yoff: ((off[BOTTOM] - off[TOP])), xoff: (off[RIGHT] - off[LEFT]), inRegion: DOM.inRegion(node, node2, false, altRegion) }; }
[ "function", "(", "node", ",", "node2", ",", "altRegion", ")", "{", "var", "r", "=", "altRegion", "||", "DOM", ".", "region", "(", "node", ")", ",", "region", "=", "{", "}", ",", "n", "=", "node2", ",", "off", ";", "if", "(", "n", ".", "tagName", ")", "{", "region", "=", "DOM", ".", "region", "(", "n", ")", ";", "}", "else", "if", "(", "Y", ".", "Lang", ".", "isObject", "(", "node2", ")", ")", "{", "region", "=", "node2", ";", "}", "else", "{", "return", "false", ";", "}", "off", "=", "getOffsets", "(", "region", ",", "r", ")", ";", "return", "{", "top", ":", "off", "[", "TOP", "]", ",", "right", ":", "off", "[", "RIGHT", "]", ",", "bottom", ":", "off", "[", "BOTTOM", "]", ",", "left", ":", "off", "[", "LEFT", "]", ",", "area", ":", "(", "(", "off", "[", "BOTTOM", "]", "-", "off", "[", "TOP", "]", ")", "*", "(", "off", "[", "RIGHT", "]", "-", "off", "[", "LEFT", "]", ")", ")", ",", "yoff", ":", "(", "(", "off", "[", "BOTTOM", "]", "-", "off", "[", "TOP", "]", ")", ")", ",", "xoff", ":", "(", "off", "[", "RIGHT", "]", "-", "off", "[", "LEFT", "]", ")", ",", "inRegion", ":", "DOM", ".", "inRegion", "(", "node", ",", "node2", ",", "false", ",", "altRegion", ")", "}", ";", "}" ]
Find the intersect information for the passes nodes. @method intersect @for DOM @param {HTMLElement} element The first element @param {HTMLElement | Object} element2 The element or region to check the interect with @param {Object} altRegion An object literal containing the region for the first element if we already have the data (for performance i.e. DragDrop) @return {Object} Object literal containing the following intersection data: (top, right, bottom, left, area, yoff, xoff, inRegion)
[ "Find", "the", "intersect", "information", "for", "the", "passes", "nodes", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L5844-L5869
57,681
5long/roil
src/console/simpleyui.js
function(node, node2, all, altRegion) { var region = {}, r = altRegion || DOM.region(node), n = node2, off; if (n.tagName) { region = DOM.region(n); } else if (Y.Lang.isObject(node2)) { region = node2; } else { return false; } if (all) { return ( r[LEFT] >= region[LEFT] && r[RIGHT] <= region[RIGHT] && r[TOP] >= region[TOP] && r[BOTTOM] <= region[BOTTOM] ); } else { off = getOffsets(region, r); if (off[BOTTOM] >= off[TOP] && off[RIGHT] >= off[LEFT]) { return true; } else { return false; } } }
javascript
function(node, node2, all, altRegion) { var region = {}, r = altRegion || DOM.region(node), n = node2, off; if (n.tagName) { region = DOM.region(n); } else if (Y.Lang.isObject(node2)) { region = node2; } else { return false; } if (all) { return ( r[LEFT] >= region[LEFT] && r[RIGHT] <= region[RIGHT] && r[TOP] >= region[TOP] && r[BOTTOM] <= region[BOTTOM] ); } else { off = getOffsets(region, r); if (off[BOTTOM] >= off[TOP] && off[RIGHT] >= off[LEFT]) { return true; } else { return false; } } }
[ "function", "(", "node", ",", "node2", ",", "all", ",", "altRegion", ")", "{", "var", "region", "=", "{", "}", ",", "r", "=", "altRegion", "||", "DOM", ".", "region", "(", "node", ")", ",", "n", "=", "node2", ",", "off", ";", "if", "(", "n", ".", "tagName", ")", "{", "region", "=", "DOM", ".", "region", "(", "n", ")", ";", "}", "else", "if", "(", "Y", ".", "Lang", ".", "isObject", "(", "node2", ")", ")", "{", "region", "=", "node2", ";", "}", "else", "{", "return", "false", ";", "}", "if", "(", "all", ")", "{", "return", "(", "r", "[", "LEFT", "]", ">=", "region", "[", "LEFT", "]", "&&", "r", "[", "RIGHT", "]", "<=", "region", "[", "RIGHT", "]", "&&", "r", "[", "TOP", "]", ">=", "region", "[", "TOP", "]", "&&", "r", "[", "BOTTOM", "]", "<=", "region", "[", "BOTTOM", "]", ")", ";", "}", "else", "{", "off", "=", "getOffsets", "(", "region", ",", "r", ")", ";", "if", "(", "off", "[", "BOTTOM", "]", ">=", "off", "[", "TOP", "]", "&&", "off", "[", "RIGHT", "]", ">=", "off", "[", "LEFT", "]", ")", "{", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}", "}" ]
Check if any part of this node is in the passed region @method inRegion @for DOM @param {Object} node2 The node to get the region from or an Object literal of the region $param {Boolean} all Should all of the node be inside the region @param {Object} altRegion An object literal containing the region for this node if we already have the data (for performance i.e. DragDrop) @return {Boolean} True if in region, false if not.
[ "Check", "if", "any", "part", "of", "this", "node", "is", "in", "the", "passed", "region" ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L5879-L5908
57,682
5long/roil
src/console/simpleyui.js
function(node, all, altRegion) { return DOM.inRegion(node, DOM.viewportRegion(node), all, altRegion); }
javascript
function(node, all, altRegion) { return DOM.inRegion(node, DOM.viewportRegion(node), all, altRegion); }
[ "function", "(", "node", ",", "all", ",", "altRegion", ")", "{", "return", "DOM", ".", "inRegion", "(", "node", ",", "DOM", ".", "viewportRegion", "(", "node", ")", ",", "all", ",", "altRegion", ")", ";", "}" ]
Check if any part of this element is in the viewport @method inViewportRegion @for DOM @param {HTMLElement} element The DOM element. @param {Boolean} all Should all of the node be inside the region @param {Object} altRegion An object literal containing the region for this node if we already have the data (for performance i.e. DragDrop) @return {Boolean} True if in region, false if not.
[ "Check", "if", "any", "part", "of", "this", "element", "is", "in", "the", "viewport" ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L5919-L5922
57,683
5long/roil
src/console/simpleyui.js
function(selector) { selector = selector || ''; selector = Selector._replaceShorthand(Y.Lang.trim(selector)); var token = Selector._getToken(), // one token per simple selector (left selector holds combinator) query = selector, // original query for debug report tokens = [], // array of tokens found = false, // whether or not any matches were found this pass match, // the regex match test, i, parser; /* Search for selector patterns, store, and strip them from the selector string until no patterns match (invalid selector) or we run out of chars. Multiple attributes and pseudos are allowed, in any order. for example: 'form:first-child[type=button]:not(button)[lang|=en]' */ outer: do { found = false; // reset after full pass for (i = 0; (parser = Selector._parsers[i++]);) { if ( (match = parser.re.exec(selector)) ) { // note assignment if (parser.name !== COMBINATOR ) { token.selector = selector; } selector = selector.replace(match[0], ''); // strip current match from selector if (!selector.length) { token.last = true; } if (Selector._attrFilters[match[1]]) { // convert class to className, etc. match[1] = Selector._attrFilters[match[1]]; } test = parser.fn(match, token); if (test === false) { // selector not supported found = false; break outer; } else if (test) { token.tests.push(test); } if (!selector.length || parser.name === COMBINATOR) { tokens.push(token); token = Selector._getToken(token); if (parser.name === COMBINATOR) { token.combinator = Y.Selector.combinators[match[1]]; } } found = true; } } } while (found && selector.length); if (!found || selector.length) { // not fully parsed tokens = []; } return tokens; }
javascript
function(selector) { selector = selector || ''; selector = Selector._replaceShorthand(Y.Lang.trim(selector)); var token = Selector._getToken(), // one token per simple selector (left selector holds combinator) query = selector, // original query for debug report tokens = [], // array of tokens found = false, // whether or not any matches were found this pass match, // the regex match test, i, parser; /* Search for selector patterns, store, and strip them from the selector string until no patterns match (invalid selector) or we run out of chars. Multiple attributes and pseudos are allowed, in any order. for example: 'form:first-child[type=button]:not(button)[lang|=en]' */ outer: do { found = false; // reset after full pass for (i = 0; (parser = Selector._parsers[i++]);) { if ( (match = parser.re.exec(selector)) ) { // note assignment if (parser.name !== COMBINATOR ) { token.selector = selector; } selector = selector.replace(match[0], ''); // strip current match from selector if (!selector.length) { token.last = true; } if (Selector._attrFilters[match[1]]) { // convert class to className, etc. match[1] = Selector._attrFilters[match[1]]; } test = parser.fn(match, token); if (test === false) { // selector not supported found = false; break outer; } else if (test) { token.tests.push(test); } if (!selector.length || parser.name === COMBINATOR) { tokens.push(token); token = Selector._getToken(token); if (parser.name === COMBINATOR) { token.combinator = Y.Selector.combinators[match[1]]; } } found = true; } } } while (found && selector.length); if (!found || selector.length) { // not fully parsed tokens = []; } return tokens; }
[ "function", "(", "selector", ")", "{", "selector", "=", "selector", "||", "''", ";", "selector", "=", "Selector", ".", "_replaceShorthand", "(", "Y", ".", "Lang", ".", "trim", "(", "selector", ")", ")", ";", "var", "token", "=", "Selector", ".", "_getToken", "(", ")", ",", "// one token per simple selector (left selector holds combinator)", "query", "=", "selector", ",", "// original query for debug report", "tokens", "=", "[", "]", ",", "// array of tokens", "found", "=", "false", ",", "// whether or not any matches were found this pass", "match", ",", "// the regex match", "test", ",", "i", ",", "parser", ";", "/*\n Search for selector patterns, store, and strip them from the selector string\n until no patterns match (invalid selector) or we run out of chars.\n\n Multiple attributes and pseudos are allowed, in any order.\n for example:\n 'form:first-child[type=button]:not(button)[lang|=en]'\n */", "outer", ":", "do", "{", "found", "=", "false", ";", "// reset after full pass", "for", "(", "i", "=", "0", ";", "(", "parser", "=", "Selector", ".", "_parsers", "[", "i", "++", "]", ")", ";", ")", "{", "if", "(", "(", "match", "=", "parser", ".", "re", ".", "exec", "(", "selector", ")", ")", ")", "{", "// note assignment", "if", "(", "parser", ".", "name", "!==", "COMBINATOR", ")", "{", "token", ".", "selector", "=", "selector", ";", "}", "selector", "=", "selector", ".", "replace", "(", "match", "[", "0", "]", ",", "''", ")", ";", "// strip current match from selector", "if", "(", "!", "selector", ".", "length", ")", "{", "token", ".", "last", "=", "true", ";", "}", "if", "(", "Selector", ".", "_attrFilters", "[", "match", "[", "1", "]", "]", ")", "{", "// convert class to className, etc.", "match", "[", "1", "]", "=", "Selector", ".", "_attrFilters", "[", "match", "[", "1", "]", "]", ";", "}", "test", "=", "parser", ".", "fn", "(", "match", ",", "token", ")", ";", "if", "(", "test", "===", "false", ")", "{", "// selector not supported", "found", "=", "false", ";", "break", "outer", ";", "}", "else", "if", "(", "test", ")", "{", "token", ".", "tests", ".", "push", "(", "test", ")", ";", "}", "if", "(", "!", "selector", ".", "length", "||", "parser", ".", "name", "===", "COMBINATOR", ")", "{", "tokens", ".", "push", "(", "token", ")", ";", "token", "=", "Selector", ".", "_getToken", "(", "token", ")", ";", "if", "(", "parser", ".", "name", "===", "COMBINATOR", ")", "{", "token", ".", "combinator", "=", "Y", ".", "Selector", ".", "combinators", "[", "match", "[", "1", "]", "]", ";", "}", "}", "found", "=", "true", ";", "}", "}", "}", "while", "(", "found", "&&", "selector", ".", "length", ")", ";", "if", "(", "!", "found", "||", "selector", ".", "length", ")", "{", "// not fully parsed", "tokens", "=", "[", "]", ";", "}", "return", "tokens", ";", "}" ]
Break selector into token units per simple selector. Combinator is attached to the previous token.
[ "Break", "selector", "into", "token", "units", "per", "simple", "selector", ".", "Combinator", "is", "attached", "to", "the", "previous", "token", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L6561-L6621
57,684
5long/roil
src/console/simpleyui.js
function(fn, obj, sFn, c) { var f = fn, a; if (c) { a = [fn, c].concat(Y.Array(arguments, 4, true)); f = Y.rbind.apply(Y, a); } return this._inject(BEFORE, f, obj, sFn); }
javascript
function(fn, obj, sFn, c) { var f = fn, a; if (c) { a = [fn, c].concat(Y.Array(arguments, 4, true)); f = Y.rbind.apply(Y, a); } return this._inject(BEFORE, f, obj, sFn); }
[ "function", "(", "fn", ",", "obj", ",", "sFn", ",", "c", ")", "{", "var", "f", "=", "fn", ",", "a", ";", "if", "(", "c", ")", "{", "a", "=", "[", "fn", ",", "c", "]", ".", "concat", "(", "Y", ".", "Array", "(", "arguments", ",", "4", ",", "true", ")", ")", ";", "f", "=", "Y", ".", "rbind", ".", "apply", "(", "Y", ",", "a", ")", ";", "}", "return", "this", ".", "_inject", "(", "BEFORE", ",", "f", ",", "obj", ",", "sFn", ")", ";", "}" ]
Execute the supplied method before the specified function @method before @param fn {Function} the function to execute @param obj the object hosting the method to displace @param sFn {string} the name of the method to displace @param c The execution context for fn @param arg* {mixed} 0..n additional arguments to supply to the subscriber when the event fires. @return {string} handle for the subscription @static
[ "Execute", "the", "supplied", "method", "before", "the", "specified", "function" ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L6740-L6748
57,685
5long/roil
src/console/simpleyui.js
function(when, fn, obj, sFn) { // object id var id = Y.stamp(obj), o, sid; if (! this.objs[id]) { // create a map entry for the obj if it doesn't exist this.objs[id] = {}; } o = this.objs[id]; if (! o[sFn]) { // create a map entry for the method if it doesn't exist o[sFn] = new Y.Do.Method(obj, sFn); // re-route the method to our wrapper obj[sFn] = function() { return o[sFn].exec.apply(o[sFn], arguments); }; } // subscriber id sid = id + Y.stamp(fn) + sFn; // register the callback o[sFn].register(sid, fn, when); return new Y.EventHandle(o[sFn], sid); }
javascript
function(when, fn, obj, sFn) { // object id var id = Y.stamp(obj), o, sid; if (! this.objs[id]) { // create a map entry for the obj if it doesn't exist this.objs[id] = {}; } o = this.objs[id]; if (! o[sFn]) { // create a map entry for the method if it doesn't exist o[sFn] = new Y.Do.Method(obj, sFn); // re-route the method to our wrapper obj[sFn] = function() { return o[sFn].exec.apply(o[sFn], arguments); }; } // subscriber id sid = id + Y.stamp(fn) + sFn; // register the callback o[sFn].register(sid, fn, when); return new Y.EventHandle(o[sFn], sid); }
[ "function", "(", "when", ",", "fn", ",", "obj", ",", "sFn", ")", "{", "// object id", "var", "id", "=", "Y", ".", "stamp", "(", "obj", ")", ",", "o", ",", "sid", ";", "if", "(", "!", "this", ".", "objs", "[", "id", "]", ")", "{", "// create a map entry for the obj if it doesn't exist", "this", ".", "objs", "[", "id", "]", "=", "{", "}", ";", "}", "o", "=", "this", ".", "objs", "[", "id", "]", ";", "if", "(", "!", "o", "[", "sFn", "]", ")", "{", "// create a map entry for the method if it doesn't exist", "o", "[", "sFn", "]", "=", "new", "Y", ".", "Do", ".", "Method", "(", "obj", ",", "sFn", ")", ";", "// re-route the method to our wrapper", "obj", "[", "sFn", "]", "=", "function", "(", ")", "{", "return", "o", "[", "sFn", "]", ".", "exec", ".", "apply", "(", "o", "[", "sFn", "]", ",", "arguments", ")", ";", "}", ";", "}", "// subscriber id", "sid", "=", "id", "+", "Y", ".", "stamp", "(", "fn", ")", "+", "sFn", ";", "// register the callback", "o", "[", "sFn", "]", ".", "register", "(", "sid", ",", "fn", ",", "when", ")", ";", "return", "new", "Y", ".", "EventHandle", "(", "o", "[", "sFn", "]", ",", "sid", ")", ";", "}" ]
Execute the supplied method after the specified function @method _inject @param when {string} before or after @param fn {Function} the function to execute @param obj the object hosting the method to displace @param sFn {string} the name of the method to displace @param c The execution context for fn @return {string} handle for the subscription @private @static
[ "Execute", "the", "supplied", "method", "after", "the", "specified", "function" ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L6783-L6814
57,686
5long/roil
src/console/simpleyui.js
function() { var evt = this.evt, detached = 0, i; if (evt) { if (Y.Lang.isArray(evt)) { for (i=0; i<evt.length; i++) { detached += evt[i].detach(); } } else { evt._delete(this.sub); detached = 1; } } return detached; }
javascript
function() { var evt = this.evt, detached = 0, i; if (evt) { if (Y.Lang.isArray(evt)) { for (i=0; i<evt.length; i++) { detached += evt[i].detach(); } } else { evt._delete(this.sub); detached = 1; } } return detached; }
[ "function", "(", ")", "{", "var", "evt", "=", "this", ".", "evt", ",", "detached", "=", "0", ",", "i", ";", "if", "(", "evt", ")", "{", "if", "(", "Y", ".", "Lang", ".", "isArray", "(", "evt", ")", ")", "{", "for", "(", "i", "=", "0", ";", "i", "<", "evt", ".", "length", ";", "i", "++", ")", "{", "detached", "+=", "evt", "[", "i", "]", ".", "detach", "(", ")", ";", "}", "}", "else", "{", "evt", ".", "_delete", "(", "this", ".", "sub", ")", ";", "detached", "=", "1", ";", "}", "}", "return", "detached", ";", "}" ]
Detaches this subscriber @method detach
[ "Detaches", "this", "subscriber" ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L7062-L7077
57,687
5long/roil
src/console/simpleyui.js
function(what) { this.monitored = true; var type = this.id + '|' + this.type + '_' + what, args = Y.Array(arguments, 0, true); args[0] = type; return this.host.on.apply(this.host, args); }
javascript
function(what) { this.monitored = true; var type = this.id + '|' + this.type + '_' + what, args = Y.Array(arguments, 0, true); args[0] = type; return this.host.on.apply(this.host, args); }
[ "function", "(", "what", ")", "{", "this", ".", "monitored", "=", "true", ";", "var", "type", "=", "this", ".", "id", "+", "'|'", "+", "this", ".", "type", "+", "'_'", "+", "what", ",", "args", "=", "Y", ".", "Array", "(", "arguments", ",", "0", ",", "true", ")", ";", "args", "[", "0", "]", "=", "type", ";", "return", "this", ".", "host", ".", "on", ".", "apply", "(", "this", ".", "host", ",", "args", ")", ";", "}" ]
Monitor the event state for the subscribed event. The first parameter is what should be monitored, the rest are the normal parameters when subscribing to an event. @method monitor @param what {string} what to monitor ('detach', 'attach', 'publish') @return {EventHandle} return value from the monitor event subscription
[ "Monitor", "the", "event", "state", "for", "the", "subscribed", "event", ".", "The", "first", "parameter", "is", "what", "should", "be", "monitored", "the", "rest", "are", "the", "normal", "parameters", "when", "subscribing", "to", "an", "event", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L7344-L7350
57,688
5long/roil
src/console/simpleyui.js
function() { var s = Y.merge(this.subscribers), a = Y.merge(this.afters), sib = this.sibling; if (sib) { Y.mix(s, sib.subscribers); Y.mix(a, sib.afters); } return [s, a]; }
javascript
function() { var s = Y.merge(this.subscribers), a = Y.merge(this.afters), sib = this.sibling; if (sib) { Y.mix(s, sib.subscribers); Y.mix(a, sib.afters); } return [s, a]; }
[ "function", "(", ")", "{", "var", "s", "=", "Y", ".", "merge", "(", "this", ".", "subscribers", ")", ",", "a", "=", "Y", ".", "merge", "(", "this", ".", "afters", ")", ",", "sib", "=", "this", ".", "sibling", ";", "if", "(", "sib", ")", "{", "Y", ".", "mix", "(", "s", ",", "sib", ".", "subscribers", ")", ";", "Y", ".", "mix", "(", "a", ",", "sib", ".", "afters", ")", ";", "}", "return", "[", "s", ",", "a", "]", ";", "}" ]
Get all of the subscribers to this event and any sibling event @return {Array} first item is the on subscribers, second the after
[ "Get", "all", "of", "the", "subscribers", "to", "this", "event", "and", "any", "sibling", "event" ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L7356-L7365
57,689
5long/roil
src/console/simpleyui.js
function(fn, context) { // unsubscribe handle if (fn && fn.detach) { return fn.detach(); } var i, s, found = 0, subs = Y.merge(this.subscribers, this.afters); for (i in subs) { if (subs.hasOwnProperty(i)) { s = subs[i]; if (s && (!fn || fn === s.fn)) { this._delete(s); found++; } } } return found; }
javascript
function(fn, context) { // unsubscribe handle if (fn && fn.detach) { return fn.detach(); } var i, s, found = 0, subs = Y.merge(this.subscribers, this.afters); for (i in subs) { if (subs.hasOwnProperty(i)) { s = subs[i]; if (s && (!fn || fn === s.fn)) { this._delete(s); found++; } } } return found; }
[ "function", "(", "fn", ",", "context", ")", "{", "// unsubscribe handle", "if", "(", "fn", "&&", "fn", ".", "detach", ")", "{", "return", "fn", ".", "detach", "(", ")", ";", "}", "var", "i", ",", "s", ",", "found", "=", "0", ",", "subs", "=", "Y", ".", "merge", "(", "this", ".", "subscribers", ",", "this", ".", "afters", ")", ";", "for", "(", "i", "in", "subs", ")", "{", "if", "(", "subs", ".", "hasOwnProperty", "(", "i", ")", ")", "{", "s", "=", "subs", "[", "i", "]", ";", "if", "(", "s", "&&", "(", "!", "fn", "||", "fn", "===", "s", ".", "fn", ")", ")", "{", "this", ".", "_delete", "(", "s", ")", ";", "found", "++", ";", "}", "}", "}", "return", "found", ";", "}" ]
Detach listeners. @method detach @param {Function} fn The subscribed function to remove, if not supplied all will be removed @param {Object} context The context object passed to subscribe. @return {int} returns the number of subscribers unsubscribed
[ "Detach", "listeners", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L7463-L7484
57,690
5long/roil
src/console/simpleyui.js
function(s, args, ef) { this.log(this.type + "->" + "sub: " + s.id); var ret; ret = s.notify(args, this); if (false === ret || this.stopped > 1) { this.log(this.type + " cancelled by subscriber"); return false; } return true; }
javascript
function(s, args, ef) { this.log(this.type + "->" + "sub: " + s.id); var ret; ret = s.notify(args, this); if (false === ret || this.stopped > 1) { this.log(this.type + " cancelled by subscriber"); return false; } return true; }
[ "function", "(", "s", ",", "args", ",", "ef", ")", "{", "this", ".", "log", "(", "this", ".", "type", "+", "\"->\"", "+", "\"sub: \"", "+", "s", ".", "id", ")", ";", "var", "ret", ";", "ret", "=", "s", ".", "notify", "(", "args", ",", "this", ")", ";", "if", "(", "false", "===", "ret", "||", "this", ".", "stopped", ">", "1", ")", "{", "this", ".", "log", "(", "this", ".", "type", "+", "\" cancelled by subscriber\"", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Notify a single subscriber @method _notify @param s {Subscriber} the subscriber @param args {Array} the arguments array to apply to the listener @private
[ "Notify", "a", "single", "subscriber" ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L7506-L7520
57,691
5long/roil
src/console/simpleyui.js
function(args, ce) { var c = this.context, ret = true; if (!c) { c = (ce.contextFn) ? ce.contextFn() : ce.context; } // only catch errors if we will not re-throw them. if (Y.config.throwFail) { ret = this._notify(c, args, ce); } else { try { ret = this._notify(c, args, ce); } catch(e) { Y.error(this + ' failed: ' + e.message, e); } } return ret; }
javascript
function(args, ce) { var c = this.context, ret = true; if (!c) { c = (ce.contextFn) ? ce.contextFn() : ce.context; } // only catch errors if we will not re-throw them. if (Y.config.throwFail) { ret = this._notify(c, args, ce); } else { try { ret = this._notify(c, args, ce); } catch(e) { Y.error(this + ' failed: ' + e.message, e); } } return ret; }
[ "function", "(", "args", ",", "ce", ")", "{", "var", "c", "=", "this", ".", "context", ",", "ret", "=", "true", ";", "if", "(", "!", "c", ")", "{", "c", "=", "(", "ce", ".", "contextFn", ")", "?", "ce", ".", "contextFn", "(", ")", ":", "ce", ".", "context", ";", "}", "// only catch errors if we will not re-throw them.", "if", "(", "Y", ".", "config", ".", "throwFail", ")", "{", "ret", "=", "this", ".", "_notify", "(", "c", ",", "args", ",", "ce", ")", ";", "}", "else", "{", "try", "{", "ret", "=", "this", ".", "_notify", "(", "c", ",", "args", ",", "ce", ")", ";", "}", "catch", "(", "e", ")", "{", "Y", ".", "error", "(", "this", "+", "' failed: '", "+", "e", ".", "message", ",", "e", ")", ";", "}", "}", "return", "ret", ";", "}" ]
Executes the subscriber. @method notify @param args {Array} Arguments array for the subscriber @param ce {CustomEvent} The custom event that sent the notification
[ "Executes", "the", "subscriber", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L7767-L7787
57,692
5long/roil
src/console/simpleyui.js
function(opts) { var o = (L.isObject(opts)) ? opts : {}; this._yuievt = this._yuievt || { id: Y.guid(), events: {}, targets: {}, config: o, chain: ('chain' in o) ? o.chain : Y.config.chain, bubbling: false, defaults: { context: o.context || this, host: this, emitFacade: o.emitFacade, fireOnce: o.fireOnce, queuable: o.queuable, monitored: o.monitored, broadcast: o.broadcast, defaultTargetOnly: o.defaultTargetOnly, bubbles: ('bubbles' in o) ? o.bubbles : true } }; }
javascript
function(opts) { var o = (L.isObject(opts)) ? opts : {}; this._yuievt = this._yuievt || { id: Y.guid(), events: {}, targets: {}, config: o, chain: ('chain' in o) ? o.chain : Y.config.chain, bubbling: false, defaults: { context: o.context || this, host: this, emitFacade: o.emitFacade, fireOnce: o.fireOnce, queuable: o.queuable, monitored: o.monitored, broadcast: o.broadcast, defaultTargetOnly: o.defaultTargetOnly, bubbles: ('bubbles' in o) ? o.bubbles : true } }; }
[ "function", "(", "opts", ")", "{", "var", "o", "=", "(", "L", ".", "isObject", "(", "opts", ")", ")", "?", "opts", ":", "{", "}", ";", "this", ".", "_yuievt", "=", "this", ".", "_yuievt", "||", "{", "id", ":", "Y", ".", "guid", "(", ")", ",", "events", ":", "{", "}", ",", "targets", ":", "{", "}", ",", "config", ":", "o", ",", "chain", ":", "(", "'chain'", "in", "o", ")", "?", "o", ".", "chain", ":", "Y", ".", "config", ".", "chain", ",", "bubbling", ":", "false", ",", "defaults", ":", "{", "context", ":", "o", ".", "context", "||", "this", ",", "host", ":", "this", ",", "emitFacade", ":", "o", ".", "emitFacade", ",", "fireOnce", ":", "o", ".", "fireOnce", ",", "queuable", ":", "o", ".", "queuable", ",", "monitored", ":", "o", ".", "monitored", ",", "broadcast", ":", "o", ".", "broadcast", ",", "defaultTargetOnly", ":", "o", ".", "defaultTargetOnly", ",", "bubbles", ":", "(", "'bubbles'", "in", "o", ")", "?", "o", ".", "bubbles", ":", "true", "}", "}", ";", "}" ]
EventTarget provides the implementation for any object to publish, subscribe and fire to custom events, and also alows other EventTargets to target the object with events sourced from the other object. EventTarget is designed to be used with Y.augment to wrap EventCustom in an interface that allows events to be listened to and fired by name. This makes it possible for implementing code to subscribe to an event that either has not been created yet, or will not be created at all. @class EventTarget @param opts a configuration object @config emitFacade {boolean} if true, all events will emit event facade payloads by default (default false) @config prefix {string} the prefix to apply to non-prefixed event names @config chain {boolean} if true, on/after/detach return the host to allow chaining, otherwise they return an EventHandle (default false)
[ "EventTarget", "provides", "the", "implementation", "for", "any", "object", "to", "publish", "subscribe", "and", "fire", "to", "custom", "events", "and", "also", "alows", "other", "EventTargets", "to", "target", "the", "object", "with", "events", "sourced", "from", "the", "other", "object", ".", "EventTarget", "is", "designed", "to", "be", "used", "with", "Y", ".", "augment", "to", "wrap", "EventCustom", "in", "an", "interface", "that", "allows", "events", "to", "be", "listened", "to", "and", "fired", "by", "name", ".", "This", "makes", "it", "possible", "for", "implementing", "code", "to", "subscribe", "to", "an", "event", "that", "either", "has", "not", "been", "created", "yet", "or", "will", "not", "be", "created", "at", "all", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L7898-L7930
57,693
5long/roil
src/console/simpleyui.js
function(type) { var typeIncluded = L.isString(type), t = (typeIncluded) ? type : (type && type.type), ce, ret, pre = this._yuievt.config.prefix, ce2, args = (typeIncluded) ? YArray(arguments, 1, true) : arguments; t = (pre) ? _getType(t, pre) : t; this._monitor('fire', t, { args: args }); ce = this.getEvent(t, true); ce2 = this.getSibling(t, ce); if (ce2 && !ce) { ce = this.publish(t); } // this event has not been published or subscribed to if (!ce) { if (this._yuievt.hasTargets) { return this.bubble({ type: t }, args, this); } // otherwise there is nothing to be done ret = true; } else { ce.sibling = ce2; ret = ce.fire.apply(ce, args); } return (this._yuievt.chain) ? this : ret; }
javascript
function(type) { var typeIncluded = L.isString(type), t = (typeIncluded) ? type : (type && type.type), ce, ret, pre = this._yuievt.config.prefix, ce2, args = (typeIncluded) ? YArray(arguments, 1, true) : arguments; t = (pre) ? _getType(t, pre) : t; this._monitor('fire', t, { args: args }); ce = this.getEvent(t, true); ce2 = this.getSibling(t, ce); if (ce2 && !ce) { ce = this.publish(t); } // this event has not been published or subscribed to if (!ce) { if (this._yuievt.hasTargets) { return this.bubble({ type: t }, args, this); } // otherwise there is nothing to be done ret = true; } else { ce.sibling = ce2; ret = ce.fire.apply(ce, args); } return (this._yuievt.chain) ? this : ret; }
[ "function", "(", "type", ")", "{", "var", "typeIncluded", "=", "L", ".", "isString", "(", "type", ")", ",", "t", "=", "(", "typeIncluded", ")", "?", "type", ":", "(", "type", "&&", "type", ".", "type", ")", ",", "ce", ",", "ret", ",", "pre", "=", "this", ".", "_yuievt", ".", "config", ".", "prefix", ",", "ce2", ",", "args", "=", "(", "typeIncluded", ")", "?", "YArray", "(", "arguments", ",", "1", ",", "true", ")", ":", "arguments", ";", "t", "=", "(", "pre", ")", "?", "_getType", "(", "t", ",", "pre", ")", ":", "t", ";", "this", ".", "_monitor", "(", "'fire'", ",", "t", ",", "{", "args", ":", "args", "}", ")", ";", "ce", "=", "this", ".", "getEvent", "(", "t", ",", "true", ")", ";", "ce2", "=", "this", ".", "getSibling", "(", "t", ",", "ce", ")", ";", "if", "(", "ce2", "&&", "!", "ce", ")", "{", "ce", "=", "this", ".", "publish", "(", "t", ")", ";", "}", "// this event has not been published or subscribed to", "if", "(", "!", "ce", ")", "{", "if", "(", "this", ".", "_yuievt", ".", "hasTargets", ")", "{", "return", "this", ".", "bubble", "(", "{", "type", ":", "t", "}", ",", "args", ",", "this", ")", ";", "}", "// otherwise there is nothing to be done", "ret", "=", "true", ";", "}", "else", "{", "ce", ".", "sibling", "=", "ce2", ";", "ret", "=", "ce", ".", "fire", ".", "apply", "(", "ce", ",", "args", ")", ";", "}", "return", "(", "this", ".", "_yuievt", ".", "chain", ")", "?", "this", ":", "ret", ";", "}" ]
Fire a custom event by name. The callback functions will be executed from the context specified when the event was created, and with the following parameters. If the custom event object hasn't been created, then the event hasn't been published and it has no subscribers. For performance sake, we immediate exit in this case. This means the event won't bubble, so if the intention is that a bubble target be notified, the event must be published on this object first. The first argument is the event type, and any additional arguments are passed to the listeners as parameters. If the first of these is an object literal, and the event is configured to emit an event facade, that object is mixed into the event facade and the facade is provided in place of the original object. @method fire @param type {String|Object} The type of the event, or an object that contains a 'type' property. @param arguments {Object*} an arbitrary set of parameters to pass to the handler. If the first of these is an object literal and the event is configured to emit an event facade, the event facade will replace that parameter after the properties the object literal contains are copied to the event facade. @return {EventTarget} the event host
[ "Fire", "a", "custom", "event", "by", "name", ".", "The", "callback", "functions", "will", "be", "executed", "from", "the", "context", "specified", "when", "the", "event", "was", "created", "and", "with", "the", "following", "parameters", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L8390-L8424
57,694
5long/roil
src/console/simpleyui.js
function(type, prefixed) { var pre, e; if (!prefixed) { pre = this._yuievt.config.prefix; type = (pre) ? _getType(type, pre) : type; } e = this._yuievt.events; return e[type] || null; }
javascript
function(type, prefixed) { var pre, e; if (!prefixed) { pre = this._yuievt.config.prefix; type = (pre) ? _getType(type, pre) : type; } e = this._yuievt.events; return e[type] || null; }
[ "function", "(", "type", ",", "prefixed", ")", "{", "var", "pre", ",", "e", ";", "if", "(", "!", "prefixed", ")", "{", "pre", "=", "this", ".", "_yuievt", ".", "config", ".", "prefix", ";", "type", "=", "(", "pre", ")", "?", "_getType", "(", "type", ",", "pre", ")", ":", "type", ";", "}", "e", "=", "this", ".", "_yuievt", ".", "events", ";", "return", "e", "[", "type", "]", "||", "null", ";", "}" ]
Returns the custom event of the provided type has been created, a falsy value otherwise @method getEvent @param type {string} the type, or name of the event @param prefixed {string} if true, the type is prefixed already @return {CustomEvent} the custom event or null
[ "Returns", "the", "custom", "event", "of", "the", "provided", "type", "has", "been", "created", "a", "falsy", "value", "otherwise" ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L8453-L8461
57,695
5long/roil
src/console/simpleyui.js
function(type, fn) { var a = YArray(arguments, 0, true); switch (L.type(type)) { case 'function': return Y.Do.after.apply(Y.Do, arguments); case 'array': // YArray.each(a[0], function(v) { // v = AFTER_PREFIX + v; // }); // break; case 'object': a[0]._after = true; break; default: a[0] = AFTER_PREFIX + type; } return this.on.apply(this, a); }
javascript
function(type, fn) { var a = YArray(arguments, 0, true); switch (L.type(type)) { case 'function': return Y.Do.after.apply(Y.Do, arguments); case 'array': // YArray.each(a[0], function(v) { // v = AFTER_PREFIX + v; // }); // break; case 'object': a[0]._after = true; break; default: a[0] = AFTER_PREFIX + type; } return this.on.apply(this, a); }
[ "function", "(", "type", ",", "fn", ")", "{", "var", "a", "=", "YArray", "(", "arguments", ",", "0", ",", "true", ")", ";", "switch", "(", "L", ".", "type", "(", "type", ")", ")", "{", "case", "'function'", ":", "return", "Y", ".", "Do", ".", "after", ".", "apply", "(", "Y", ".", "Do", ",", "arguments", ")", ";", "case", "'array'", ":", "// YArray.each(a[0], function(v) {", "// v = AFTER_PREFIX + v;", "// });", "// break;", "case", "'object'", ":", "a", "[", "0", "]", ".", "_after", "=", "true", ";", "break", ";", "default", ":", "a", "[", "0", "]", "=", "AFTER_PREFIX", "+", "type", ";", "}", "return", "this", ".", "on", ".", "apply", "(", "this", ",", "a", ")", ";", "}" ]
Subscribe to a custom event hosted by this object. The supplied callback will execute after any listeners add via the subscribe method, and after the default function, if configured for the event, has executed. @method after @param type {string} The type of the event @param fn {Function} The callback @param context {object} optional execution context. @param arg* {mixed} 0..n additional arguments to supply to the subscriber @return the event target or a detach handle per 'chain' config
[ "Subscribe", "to", "a", "custom", "event", "hosted", "by", "this", "object", ".", "The", "supplied", "callback", "will", "execute", "after", "any", "listeners", "add", "via", "the", "subscribe", "method", "and", "after", "the", "default", "function", "if", "configured", "for", "the", "event", "has", "executed", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L8475-L8496
57,696
5long/roil
src/console/simpleyui.js
function(type, fn, el, obj) { var args=Y.Array(arguments, 0, true), compat, l, ok, i, id, ce; if (args[args.length-1] === COMPAT_ARG) { compat = true; // args.pop(); } if (type && type.detach) { return type.detach(); } // The el argument can be a string if (typeof el == "string") { // el = (compat) ? Y.DOM.byId(el) : Y.all(el); if (compat) { el = Y.DOM.byId(el); } else { el = Y.Selector.query(el); l = el.length; if (l < 1) { el = null; } else if (l == 1) { el = el[0]; } } // return Event.detach.apply(Event, args); } if (!el) { return false; } if (el.detach) { args.splice(2, 1); return el.detach.apply(el, args); // The el argument can be an array of elements or element ids. } else if (shouldIterate(el)) { ok = true; for (i=0, l=el.length; i<l; ++i) { args[2] = el[i]; ok = ( Y.Event.detach.apply(Y.Event, args) && ok ); } return ok; } if (!type || !fn || !fn.call) { return this.purgeElement(el, false, type); } id = 'event:' + Y.stamp(el) + type; ce = _wrappers[id]; if (ce) { return ce.detach(fn); } else { return false; } }
javascript
function(type, fn, el, obj) { var args=Y.Array(arguments, 0, true), compat, l, ok, i, id, ce; if (args[args.length-1] === COMPAT_ARG) { compat = true; // args.pop(); } if (type && type.detach) { return type.detach(); } // The el argument can be a string if (typeof el == "string") { // el = (compat) ? Y.DOM.byId(el) : Y.all(el); if (compat) { el = Y.DOM.byId(el); } else { el = Y.Selector.query(el); l = el.length; if (l < 1) { el = null; } else if (l == 1) { el = el[0]; } } // return Event.detach.apply(Event, args); } if (!el) { return false; } if (el.detach) { args.splice(2, 1); return el.detach.apply(el, args); // The el argument can be an array of elements or element ids. } else if (shouldIterate(el)) { ok = true; for (i=0, l=el.length; i<l; ++i) { args[2] = el[i]; ok = ( Y.Event.detach.apply(Y.Event, args) && ok ); } return ok; } if (!type || !fn || !fn.call) { return this.purgeElement(el, false, type); } id = 'event:' + Y.stamp(el) + type; ce = _wrappers[id]; if (ce) { return ce.detach(fn); } else { return false; } }
[ "function", "(", "type", ",", "fn", ",", "el", ",", "obj", ")", "{", "var", "args", "=", "Y", ".", "Array", "(", "arguments", ",", "0", ",", "true", ")", ",", "compat", ",", "l", ",", "ok", ",", "i", ",", "id", ",", "ce", ";", "if", "(", "args", "[", "args", ".", "length", "-", "1", "]", "===", "COMPAT_ARG", ")", "{", "compat", "=", "true", ";", "// args.pop();", "}", "if", "(", "type", "&&", "type", ".", "detach", ")", "{", "return", "type", ".", "detach", "(", ")", ";", "}", "// The el argument can be a string", "if", "(", "typeof", "el", "==", "\"string\"", ")", "{", "// el = (compat) ? Y.DOM.byId(el) : Y.all(el);", "if", "(", "compat", ")", "{", "el", "=", "Y", ".", "DOM", ".", "byId", "(", "el", ")", ";", "}", "else", "{", "el", "=", "Y", ".", "Selector", ".", "query", "(", "el", ")", ";", "l", "=", "el", ".", "length", ";", "if", "(", "l", "<", "1", ")", "{", "el", "=", "null", ";", "}", "else", "if", "(", "l", "==", "1", ")", "{", "el", "=", "el", "[", "0", "]", ";", "}", "}", "// return Event.detach.apply(Event, args);", "}", "if", "(", "!", "el", ")", "{", "return", "false", ";", "}", "if", "(", "el", ".", "detach", ")", "{", "args", ".", "splice", "(", "2", ",", "1", ")", ";", "return", "el", ".", "detach", ".", "apply", "(", "el", ",", "args", ")", ";", "// The el argument can be an array of elements or element ids.", "}", "else", "if", "(", "shouldIterate", "(", "el", ")", ")", "{", "ok", "=", "true", ";", "for", "(", "i", "=", "0", ",", "l", "=", "el", ".", "length", ";", "i", "<", "l", ";", "++", "i", ")", "{", "args", "[", "2", "]", "=", "el", "[", "i", "]", ";", "ok", "=", "(", "Y", ".", "Event", ".", "detach", ".", "apply", "(", "Y", ".", "Event", ",", "args", ")", "&&", "ok", ")", ";", "}", "return", "ok", ";", "}", "if", "(", "!", "type", "||", "!", "fn", "||", "!", "fn", ".", "call", ")", "{", "return", "this", ".", "purgeElement", "(", "el", ",", "false", ",", "type", ")", ";", "}", "id", "=", "'event:'", "+", "Y", ".", "stamp", "(", "el", ")", "+", "type", ";", "ce", "=", "_wrappers", "[", "id", "]", ";", "if", "(", "ce", ")", "{", "return", "ce", ".", "detach", "(", "fn", ")", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Removes an event listener. Supports the signature the event was bound with, but the preferred way to remove listeners is using the handle that is returned when using Y.on @method detach @param {String} type the type of event to remove. @param {Function} fn the method the event invokes. If fn is undefined, then all event handlers for the type of event are removed. @param {String|HTMLElement|Array|NodeList|EventHandle} el An event handle, an id, an element reference, or a collection of ids and/or elements to remove the listener from. @return {boolean} true if the unbind was successful, false otherwise. @static
[ "Removes", "an", "event", "listener", ".", "Supports", "the", "signature", "the", "event", "was", "bound", "with", "but", "the", "preferred", "way", "to", "remove", "listeners", "is", "using", "the", "handle", "that", "is", "returned", "when", "using", "Y", ".", "on" ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L9578-L9641
57,697
5long/roil
src/console/simpleyui.js
function(p, config) { if (p) { if (L.isFunction(p)) { this._plug(p, config); } else if (L.isArray(p)) { for (var i = 0, ln = p.length; i < ln; i++) { this.plug(p[i]); } } else { this._plug(p.fn, p.cfg); } } return this; }
javascript
function(p, config) { if (p) { if (L.isFunction(p)) { this._plug(p, config); } else if (L.isArray(p)) { for (var i = 0, ln = p.length; i < ln; i++) { this.plug(p[i]); } } else { this._plug(p.fn, p.cfg); } } return this; }
[ "function", "(", "p", ",", "config", ")", "{", "if", "(", "p", ")", "{", "if", "(", "L", ".", "isFunction", "(", "p", ")", ")", "{", "this", ".", "_plug", "(", "p", ",", "config", ")", ";", "}", "else", "if", "(", "L", ".", "isArray", "(", "p", ")", ")", "{", "for", "(", "var", "i", "=", "0", ",", "ln", "=", "p", ".", "length", ";", "i", "<", "ln", ";", "i", "++", ")", "{", "this", ".", "plug", "(", "p", "[", "i", "]", ")", ";", "}", "}", "else", "{", "this", ".", "_plug", "(", "p", ".", "fn", ",", "p", ".", "cfg", ")", ";", "}", "}", "return", "this", ";", "}" ]
Adds a plugin to the host object. This will instantiate the plugin and attach it to the configured namespace on the host object. @method plug @chainable @param p {Function | Object |Array} Accepts the plugin class, or an object with a "fn" property specifying the plugin class and a "cfg" property specifying the configuration for the Plugin. <p> Additionally an Array can also be passed in, with the above function or object values, allowing the user to add multiple plugins in a single call. </p> @param config (Optional) If the first argument is the plugin class, the second argument can be the configuration for the plugin. @return {Base} A reference to the host object
[ "Adds", "a", "plugin", "to", "the", "host", "object", ".", "This", "will", "instantiate", "the", "plugin", "and", "attach", "it", "to", "the", "configured", "namespace", "on", "the", "host", "object", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L10095-L10108
57,698
5long/roil
src/console/simpleyui.js
function(plugin) { if (plugin) { this._unplug(plugin); } else { var ns; for (ns in this._plugins) { if (this._plugins.hasOwnProperty(ns)) { this._unplug(ns); } } } return this; }
javascript
function(plugin) { if (plugin) { this._unplug(plugin); } else { var ns; for (ns in this._plugins) { if (this._plugins.hasOwnProperty(ns)) { this._unplug(ns); } } } return this; }
[ "function", "(", "plugin", ")", "{", "if", "(", "plugin", ")", "{", "this", ".", "_unplug", "(", "plugin", ")", ";", "}", "else", "{", "var", "ns", ";", "for", "(", "ns", "in", "this", ".", "_plugins", ")", "{", "if", "(", "this", ".", "_plugins", ".", "hasOwnProperty", "(", "ns", ")", ")", "{", "this", ".", "_unplug", "(", "ns", ")", ";", "}", "}", "}", "return", "this", ";", "}" ]
Removes a plugin from the host object. This will destroy the plugin instance and delete the namepsace from the host object. @method unplug @param {String | Function} plugin The namespace of the plugin, or the plugin class with the static NS namespace property defined. If not provided, all registered plugins are unplugged. @return {Base} A reference to the host object @chainable
[ "Removes", "a", "plugin", "from", "the", "host", "object", ".", "This", "will", "destroy", "the", "plugin", "instance", "and", "delete", "the", "namepsace", "from", "the", "host", "object", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L10120-L10132
57,699
5long/roil
src/console/simpleyui.js
function(PluginClass, config) { if (PluginClass && PluginClass.NS) { var ns = PluginClass.NS; config = config || {}; config.host = this; if (this.hasPlugin(ns)) { // Update config this[ns].setAttrs(config); } else { // Create new instance this[ns] = new PluginClass(config); this._plugins[ns] = PluginClass; } } }
javascript
function(PluginClass, config) { if (PluginClass && PluginClass.NS) { var ns = PluginClass.NS; config = config || {}; config.host = this; if (this.hasPlugin(ns)) { // Update config this[ns].setAttrs(config); } else { // Create new instance this[ns] = new PluginClass(config); this._plugins[ns] = PluginClass; } } }
[ "function", "(", "PluginClass", ",", "config", ")", "{", "if", "(", "PluginClass", "&&", "PluginClass", ".", "NS", ")", "{", "var", "ns", "=", "PluginClass", ".", "NS", ";", "config", "=", "config", "||", "{", "}", ";", "config", ".", "host", "=", "this", ";", "if", "(", "this", ".", "hasPlugin", "(", "ns", ")", ")", "{", "// Update config", "this", "[", "ns", "]", ".", "setAttrs", "(", "config", ")", ";", "}", "else", "{", "// Create new instance", "this", "[", "ns", "]", "=", "new", "PluginClass", "(", "config", ")", ";", "this", ".", "_plugins", "[", "ns", "]", "=", "PluginClass", ";", "}", "}", "}" ]
Private method used to instantiate and attach plugins to the host @method _plug @param {Function} PluginClass The plugin class to instantiate @param {Object} config The configuration object for the plugin @private
[ "Private", "method", "used", "to", "instantiate", "and", "attach", "plugins", "to", "the", "host" ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L10211-L10227