repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
partition
stringclasses
1 value
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
train
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
train
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
train
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", "=", "[", "]", ";", "this", ".", "handlers", "=", "new", "Promise", "(", "function", "(", "resolve", ")", "{", "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
train
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", ")", "{", "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
train
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
train
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
train
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", "{", "Y", ".", "_init", "(", ")", ";", "if", "(", "gconf", ")", "{", "Y", ".", "applyConfig", "(", "gconf", ")", ";", "}", "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
train
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
train
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
train
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
train
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
train
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\"", ")", ";", "}", "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
train
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
train
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", ";", "}", "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
train
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
train
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
train
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", ";", "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", ";", "}", "while", "(", "language", ".", "length", ">", "0", ")", "{", "result", "=", "scan", "(", "language", ")", ";", "if", "(", "result", ")", "{", "return", "result", ";", "}", "else", "{", "index", "=", "language", ".", "lastIndexOf", "(", "\"-\"", ")", ";", "if", "(", "index", ">=", "0", ")", "{", "language", "=", "language", ".", "substring", "(", "0", ",", "index", ")", ";", "if", "(", "index", ">=", "2", "&&", "language", ".", "charAt", "(", "index", "-", "2", ")", "===", "\"-\"", ")", "{", "language", "=", "language", ".", "substring", "(", "0", ",", "index", "-", "2", ")", ";", "}", "}", "else", "{", "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
train
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
train
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
train
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", "]", ")", ")", "{", "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
train
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", ")", "{", "ret", "=", "element", "[", "CONTAINS", "]", "(", "needle", ")", ";", "}", "else", "{", "ret", "=", "Y", ".", "DOM", ".", "_bruteContains", "(", "element", ",", "needle", ")", ";", "}", "}", "else", "if", "(", "element", "[", "COMPARE_DOCUMENT_POSITION", "]", ")", "{", "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
train
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", "]", ";", "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
train
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", ")", ";", "}", "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", ")", "{", "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", ")", "{", "ret", "=", "nodes", "[", "0", "]", ".", "parentNode", ".", "removeChild", "(", "nodes", "[", "0", "]", ")", ";", "}", "else", "if", "(", "nodes", "[", "0", "]", "&&", "nodes", "[", "0", "]", ".", "className", "===", "'yui3-big-dummy'", ")", "{", "if", "(", "nodes", ".", "length", "===", "2", ")", "{", "ret", "=", "nodes", "[", "0", "]", ".", "nextSibling", ";", "}", "else", "{", "nodes", "[", "0", "]", ".", "parentNode", ".", "removeChild", "(", "nodes", "[", "0", "]", ")", ";", "ret", "=", "Y", ".", "DOM", ".", "_nl2frag", "(", "nodes", ",", "doc", ")", ";", "}", "}", "else", "{", "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
train
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", ")", "{", "newNode", "=", "content", ";", "}", "else", "{", "newNode", "=", "Y", ".", "DOM", ".", "create", "(", "content", ")", ";", "}", "}", "if", "(", "where", ")", "{", "if", "(", "where", ".", "nodeType", ")", "{", "where", ".", "parentNode", ".", "insertBefore", "(", "newNode", ",", "where", ")", ";", "}", "else", "{", "switch", "(", "where", ")", "{", "case", "'replace'", ":", "while", "(", "node", ".", "firstChild", ")", "{", "node", ".", "removeChild", "(", "node", ".", "firstChild", ")", ";", "}", "if", "(", "newNode", ")", "{", "node", ".", "appendChild", "(", "newNode", ")", ";", "}", "break", ";", "case", "'before'", ":", "nodeParent", ".", "insertBefore", "(", "newNode", ",", "node", ")", ";", "break", ";", "case", "'after'", ":", "if", "(", "node", ".", "nextSibling", ")", "{", "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
train
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
train
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+|$)'", "}" ]
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
train
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", ")", ")", "{", "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
train
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+|$)'", ")", ")", ";", "\\\\", "}", "}" ]
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
train
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
train
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", "===", "''", ")", "{", "val", "=", "''", ";", "}", "else", "if", "(", "!", "isNaN", "(", "new", "Number", "(", "val", ")", ")", "&&", "re_unit", ".", "test", "(", "att", ")", ")", "{", "val", "+=", "Y_DOM", ".", "DEFAULT_UNIT", ";", "}", "if", "(", "att", "in", "CUSTOM_STYLES", ")", "{", "if", "(", "CUSTOM_STYLES", "[", "att", "]", ".", "set", ")", "{", "CUSTOM_STYLES", "[", "att", "]", ".", "set", "(", "node", ",", "val", ",", "style", ")", ";", "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
train
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", ")", ";", "}", "else", "if", "(", "typeof", "CUSTOM_STYLES", "[", "att", "]", "===", "'string'", ")", "{", "att", "=", "CUSTOM_STYLES", "[", "att", "]", ";", "}", "}", "val", "=", "style", "[", "att", "]", ";", "if", "(", "val", "===", "''", ")", "{", "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
train
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
train
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
train
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", ";", "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
train
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", ";", "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
train
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
train
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
train
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
train
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", "(", ")", ",", "query", "=", "selector", ",", "tokens", "=", "[", "]", ",", "found", "=", "false", ",", "match", ",", "test", ",", "i", ",", "parser", ";", "outer", ":", "do", "{", "found", "=", "false", ";", "for", "(", "i", "=", "0", ";", "(", "parser", "=", "Selector", ".", "_parsers", "[", "i", "++", "]", ")", ";", ")", "{", "if", "(", "(", "match", "=", "parser", ".", "re", ".", "exec", "(", "selector", ")", ")", ")", "{", "if", "(", "parser", ".", "name", "!==", "COMBINATOR", ")", "{", "token", ".", "selector", "=", "selector", ";", "}", "selector", "=", "selector", ".", "replace", "(", "match", "[", "0", "]", ",", "''", ")", ";", "if", "(", "!", "selector", ".", "length", ")", "{", "token", ".", "last", "=", "true", ";", "}", "if", "(", "Selector", ".", "_attrFilters", "[", "match", "[", "1", "]", "]", ")", "{", "match", "[", "1", "]", "=", "Selector", ".", "_attrFilters", "[", "match", "[", "1", "]", "]", ";", "}", "test", "=", "parser", ".", "fn", "(", "match", ",", "token", ")", ";", "if", "(", "test", "===", "false", ")", "{", "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", ")", "{", "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
train
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
train
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", ")", "{", "var", "id", "=", "Y", ".", "stamp", "(", "obj", ")", ",", "o", ",", "sid", ";", "if", "(", "!", "this", ".", "objs", "[", "id", "]", ")", "{", "this", ".", "objs", "[", "id", "]", "=", "{", "}", ";", "}", "o", "=", "this", ".", "objs", "[", "id", "]", ";", "if", "(", "!", "o", "[", "sFn", "]", ")", "{", "o", "[", "sFn", "]", "=", "new", "Y", ".", "Do", ".", "Method", "(", "obj", ",", "sFn", ")", ";", "obj", "[", "sFn", "]", "=", "function", "(", ")", "{", "return", "o", "[", "sFn", "]", ".", "exec", ".", "apply", "(", "o", "[", "sFn", "]", ",", "arguments", ")", ";", "}", ";", "}", "sid", "=", "id", "+", "Y", ".", "stamp", "(", "fn", ")", "+", "sFn", ";", "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
train
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
train
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
train
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
train
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", ")", "{", "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
train
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
train
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", ";", "}", "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
train
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
train
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", ")", ";", "}", "if", "(", "!", "ce", ")", "{", "if", "(", "this", ".", "_yuievt", ".", "hasTargets", ")", "{", "return", "this", ".", "bubble", "(", "{", "type", ":", "t", "}", ",", "args", ",", "this", ")", ";", "}", "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
train
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
train
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'", ":", "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
train
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", ";", "}", "if", "(", "type", "&&", "type", ".", "detach", ")", "{", "return", "type", ".", "detach", "(", ")", ";", "}", "if", "(", "typeof", "el", "==", "\"string\"", ")", "{", "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", "]", ";", "}", "}", "}", "if", "(", "!", "el", ")", "{", "return", "false", ";", "}", "if", "(", "el", ".", "detach", ")", "{", "args", ".", "splice", "(", "2", ",", "1", ")", ";", "return", "el", ".", "detach", ".", "apply", "(", "el", ",", "args", ")", ";", "}", "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
train
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
train
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
train
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", ")", ")", "{", "this", "[", "ns", "]", ".", "setAttrs", "(", "config", ")", ";", "}", "else", "{", "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
train
5long/roil
src/console/simpleyui.js
function(plugin) { var ns = plugin, plugins = this._plugins; if (L.isFunction(plugin)) { ns = plugin.NS; if (ns && (!plugins[ns] || plugins[ns] !== plugin)) { ns = null; } } if (ns) { if (this[ns]) { this[ns].destroy(); delete this[ns]; } if (plugins[ns]) { delete plugins[ns]; } } }
javascript
function(plugin) { var ns = plugin, plugins = this._plugins; if (L.isFunction(plugin)) { ns = plugin.NS; if (ns && (!plugins[ns] || plugins[ns] !== plugin)) { ns = null; } } if (ns) { if (this[ns]) { this[ns].destroy(); delete this[ns]; } if (plugins[ns]) { delete plugins[ns]; } } }
[ "function", "(", "plugin", ")", "{", "var", "ns", "=", "plugin", ",", "plugins", "=", "this", ".", "_plugins", ";", "if", "(", "L", ".", "isFunction", "(", "plugin", ")", ")", "{", "ns", "=", "plugin", ".", "NS", ";", "if", "(", "ns", "&&", "(", "!", "plugins", "[", "ns", "]", "||", "plugins", "[", "ns", "]", "!==", "plugin", ")", ")", "{", "ns", "=", "null", ";", "}", "}", "if", "(", "ns", ")", "{", "if", "(", "this", "[", "ns", "]", ")", "{", "this", "[", "ns", "]", ".", "destroy", "(", ")", ";", "delete", "this", "[", "ns", "]", ";", "}", "if", "(", "plugins", "[", "ns", "]", ")", "{", "delete", "plugins", "[", "ns", "]", ";", "}", "}", "}" ]
Unplugs and destroys a plugin already instantiated with the host. @method _unplug @private @param {String | Function} plugin The namespace for the plugin, or a plugin class with the static NS property defined.
[ "Unplugs", "and", "destroys", "a", "plugin", "already", "instantiated", "with", "the", "host", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L10236-L10256
train
5long/roil
src/console/simpleyui.js
function() { var str = this[UID] + ': not bound to a node', node = this._node, attrs, id, className; if (node) { attrs = node.attributes; id = (attrs && attrs.id) ? node.getAttribute('id') : null; className = (attrs && attrs.className) ? node.getAttribute('className') : null; str = node[NODE_NAME]; if (id) { str += '#' + id; } if (className) { str += '.' + className.replace(' ', '.'); } // TODO: add yuid? str += ' ' + this[UID]; } return str; }
javascript
function() { var str = this[UID] + ': not bound to a node', node = this._node, attrs, id, className; if (node) { attrs = node.attributes; id = (attrs && attrs.id) ? node.getAttribute('id') : null; className = (attrs && attrs.className) ? node.getAttribute('className') : null; str = node[NODE_NAME]; if (id) { str += '#' + id; } if (className) { str += '.' + className.replace(' ', '.'); } // TODO: add yuid? str += ' ' + this[UID]; } return str; }
[ "function", "(", ")", "{", "var", "str", "=", "this", "[", "UID", "]", "+", "': not bound to a node'", ",", "node", "=", "this", ".", "_node", ",", "attrs", ",", "id", ",", "className", ";", "if", "(", "node", ")", "{", "attrs", "=", "node", ".", "attributes", ";", "id", "=", "(", "attrs", "&&", "attrs", ".", "id", ")", "?", "node", ".", "getAttribute", "(", "'id'", ")", ":", "null", ";", "className", "=", "(", "attrs", "&&", "attrs", ".", "className", ")", "?", "node", ".", "getAttribute", "(", "'className'", ")", ":", "null", ";", "str", "=", "node", "[", "NODE_NAME", "]", ";", "if", "(", "id", ")", "{", "str", "+=", "'#'", "+", "id", ";", "}", "if", "(", "className", ")", "{", "str", "+=", "'.'", "+", "className", ".", "replace", "(", "' '", ",", "'.'", ")", ";", "}", "str", "+=", "' '", "+", "this", "[", "UID", "]", ";", "}", "return", "str", ";", "}" ]
The method called when outputting Node instances as strings @method toString @return {String} A string representation of the Node instance
[ "The", "method", "called", "when", "outputting", "Node", "instances", "as", "strings" ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L10794-L10817
train
5long/roil
src/console/simpleyui.js
function(attr) { var attrConfig = Y_Node.ATTRS[attr], val; if (attrConfig && attrConfig.getter) { val = attrConfig.getter.call(this); } else if (Y_Node.re_aria.test(attr)) { val = this._node.getAttribute(attr, 2); } else { val = Y_Node.DEFAULT_GETTER.apply(this, arguments); } return val; }
javascript
function(attr) { var attrConfig = Y_Node.ATTRS[attr], val; if (attrConfig && attrConfig.getter) { val = attrConfig.getter.call(this); } else if (Y_Node.re_aria.test(attr)) { val = this._node.getAttribute(attr, 2); } else { val = Y_Node.DEFAULT_GETTER.apply(this, arguments); } return val; }
[ "function", "(", "attr", ")", "{", "var", "attrConfig", "=", "Y_Node", ".", "ATTRS", "[", "attr", "]", ",", "val", ";", "if", "(", "attrConfig", "&&", "attrConfig", ".", "getter", ")", "{", "val", "=", "attrConfig", ".", "getter", ".", "call", "(", "this", ")", ";", "}", "else", "if", "(", "Y_Node", ".", "re_aria", ".", "test", "(", "attr", ")", ")", "{", "val", "=", "this", ".", "_node", ".", "getAttribute", "(", "attr", ",", "2", ")", ";", "}", "else", "{", "val", "=", "Y_Node", ".", "DEFAULT_GETTER", ".", "apply", "(", "this", ",", "arguments", ")", ";", "}", "return", "val", ";", "}" ]
Helper method for get. @method _get @private @param {String} attr The attribute @return {any} The current value of the attribute
[ "Helper", "method", "for", "get", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L10852-L10865
train
5long/roil
src/console/simpleyui.js
function(attrMap) { if (this._setAttrs) { // use Attribute imple this._setAttrs(attrMap); } else { // use setters inline Y.Object.each(attrMap, function(v, n) { this.set(n, v); }, this); } return this; }
javascript
function(attrMap) { if (this._setAttrs) { // use Attribute imple this._setAttrs(attrMap); } else { // use setters inline Y.Object.each(attrMap, function(v, n) { this.set(n, v); }, this); } return this; }
[ "function", "(", "attrMap", ")", "{", "if", "(", "this", ".", "_setAttrs", ")", "{", "this", ".", "_setAttrs", "(", "attrMap", ")", ";", "}", "else", "{", "Y", ".", "Object", ".", "each", "(", "attrMap", ",", "function", "(", "v", ",", "n", ")", "{", "this", ".", "set", "(", "n", ",", "v", ")", ";", "}", ",", "this", ")", ";", "}", "return", "this", ";", "}" ]
Sets multiple attributes. @method setAttrs @param {Object} attrMap an object of name/value pairs to set @chainable
[ "Sets", "multiple", "attributes", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L10902-L10912
train
5long/roil
src/console/simpleyui.js
function(attrs) { var ret = {}; if (this._getAttrs) { // use Attribute imple this._getAttrs(attrs); } else { // use setters inline Y.Array.each(attrs, function(v, n) { ret[v] = this.get(v); }, this); } return ret; }
javascript
function(attrs) { var ret = {}; if (this._getAttrs) { // use Attribute imple this._getAttrs(attrs); } else { // use setters inline Y.Array.each(attrs, function(v, n) { ret[v] = this.get(v); }, this); } return ret; }
[ "function", "(", "attrs", ")", "{", "var", "ret", "=", "{", "}", ";", "if", "(", "this", ".", "_getAttrs", ")", "{", "this", ".", "_getAttrs", "(", "attrs", ")", ";", "}", "else", "{", "Y", ".", "Array", ".", "each", "(", "attrs", ",", "function", "(", "v", ",", "n", ")", "{", "ret", "[", "v", "]", "=", "this", ".", "get", "(", "v", ")", ";", "}", ",", "this", ")", ";", "}", "return", "ret", ";", "}" ]
Returns an object containing the values for the requested attributes. @method getAttrs @param {Array} attrs an array of attributes to get values @return {Object} An object with attribute name/value pairs.
[ "Returns", "an", "object", "containing", "the", "values", "for", "the", "requested", "attributes", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L10920-L10931
train
5long/roil
src/console/simpleyui.js
function(doc) { var node = this._node; doc = (doc) ? doc._node || doc : node[OWNER_DOCUMENT]; if (doc.documentElement) { return Y_DOM.contains(doc.documentElement, node); } }
javascript
function(doc) { var node = this._node; doc = (doc) ? doc._node || doc : node[OWNER_DOCUMENT]; if (doc.documentElement) { return Y_DOM.contains(doc.documentElement, node); } }
[ "function", "(", "doc", ")", "{", "var", "node", "=", "this", ".", "_node", ";", "doc", "=", "(", "doc", ")", "?", "doc", ".", "_node", "||", "doc", ":", "node", "[", "OWNER_DOCUMENT", "]", ";", "if", "(", "doc", ".", "documentElement", ")", "{", "return", "Y_DOM", ".", "contains", "(", "doc", ".", "documentElement", ",", "node", ")", ";", "}", "}" ]
Determines whether the node is appended to the document. @method inDoc @param {Node|HTMLElement} doc optional An optional document to check against. Defaults to current document. @return {Boolean} Whether or not this node is appended to the document.
[ "Determines", "whether", "the", "node", "is", "appended", "to", "the", "document", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L10965-L10971
train
5long/roil
src/console/simpleyui.js
function(fn, testSelf) { return Y.one(Y_DOM.ancestor(this._node, _wrapFn(fn), testSelf)); }
javascript
function(fn, testSelf) { return Y.one(Y_DOM.ancestor(this._node, _wrapFn(fn), testSelf)); }
[ "function", "(", "fn", ",", "testSelf", ")", "{", "return", "Y", ".", "one", "(", "Y_DOM", ".", "ancestor", "(", "this", ".", "_node", ",", "_wrapFn", "(", "fn", ")", ",", "testSelf", ")", ")", ";", "}" ]
Returns the nearest ancestor that passes the test applied by supplied boolean method. @method ancestor @param {String | Function} fn A selector string or boolean method for testing elements. @param {Boolean} testSelf optional Whether or not to include the element in the scan If a function is used, it receives the current node being tested as the only argument. @return {Node} The matching Node instance or null if not found
[ "Returns", "the", "nearest", "ancestor", "that", "passes", "the", "test", "applied", "by", "supplied", "boolean", "method", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L10992-L10994
train
5long/roil
src/console/simpleyui.js
function(fn, all) { return Y.one(Y_DOM.elementByAxis(this._node, 'previousSibling', _wrapFn(fn), all)); }
javascript
function(fn, all) { return Y.one(Y_DOM.elementByAxis(this._node, 'previousSibling', _wrapFn(fn), all)); }
[ "function", "(", "fn", ",", "all", ")", "{", "return", "Y", ".", "one", "(", "Y_DOM", ".", "elementByAxis", "(", "this", ".", "_node", ",", "'previousSibling'", ",", "_wrapFn", "(", "fn", ")", ",", "all", ")", ")", ";", "}" ]
Returns the previous matching sibling. Returns the nearest element node sibling if no method provided. @method previous @param {String | Function} fn A selector or boolean method for testing elements. If a function is used, it receives the current node being tested as the only argument. @return {Node} Node instance or null if not found
[ "Returns", "the", "previous", "matching", "sibling", ".", "Returns", "the", "nearest", "element", "node", "sibling", "if", "no", "method", "provided", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L11004-L11006
train
5long/roil
src/console/simpleyui.js
function(content, where) { var node = this._node; if (content) { if (typeof where === 'number') { // allow index where = this._node.childNodes[where]; } else if (where && where._node) { // Node where = where._node; } if (typeof content !== 'string') { // allow Node or NodeList/Array instances if (content._node) { // Node content = content._node; } else if (content._nodes || (!content.nodeType && content.length)) { // NodeList or Array content = Y.all(content); Y.each(content._nodes, function(n) { Y_DOM.addHTML(node, n, where); }); return this; // NOTE: early return } } Y_DOM.addHTML(node, content, where); } else { } return this; }
javascript
function(content, where) { var node = this._node; if (content) { if (typeof where === 'number') { // allow index where = this._node.childNodes[where]; } else if (where && where._node) { // Node where = where._node; } if (typeof content !== 'string') { // allow Node or NodeList/Array instances if (content._node) { // Node content = content._node; } else if (content._nodes || (!content.nodeType && content.length)) { // NodeList or Array content = Y.all(content); Y.each(content._nodes, function(n) { Y_DOM.addHTML(node, n, where); }); return this; // NOTE: early return } } Y_DOM.addHTML(node, content, where); } else { } return this; }
[ "function", "(", "content", ",", "where", ")", "{", "var", "node", "=", "this", ".", "_node", ";", "if", "(", "content", ")", "{", "if", "(", "typeof", "where", "===", "'number'", ")", "{", "where", "=", "this", ".", "_node", ".", "childNodes", "[", "where", "]", ";", "}", "else", "if", "(", "where", "&&", "where", ".", "_node", ")", "{", "where", "=", "where", ".", "_node", ";", "}", "if", "(", "typeof", "content", "!==", "'string'", ")", "{", "if", "(", "content", ".", "_node", ")", "{", "content", "=", "content", ".", "_node", ";", "}", "else", "if", "(", "content", ".", "_nodes", "||", "(", "!", "content", ".", "nodeType", "&&", "content", ".", "length", ")", ")", "{", "content", "=", "Y", ".", "all", "(", "content", ")", ";", "Y", ".", "each", "(", "content", ".", "_nodes", ",", "function", "(", "n", ")", "{", "Y_DOM", ".", "addHTML", "(", "node", ",", "n", ",", "where", ")", ";", "}", ")", ";", "return", "this", ";", "}", "}", "Y_DOM", ".", "addHTML", "(", "node", ",", "content", ",", "where", ")", ";", "}", "else", "{", "}", "return", "this", ";", "}" ]
Inserts the content before the reference node. @method insert @param {String | Y.Node | HTMLElement} content The content to insert @param {Int | Y.Node | HTMLElement | String} where The position to insert at. Possible "where" arguments <dl> <dt>Y.Node</dt> <dd>The Node to insert before</dd> <dt>HTMLElement</dt> <dd>The element to insert before</dd> <dt>Int</dt> <dd>The index of the child 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> @chainable
[ "Inserts", "the", "content", "before", "the", "reference", "node", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L11248-L11274
train
5long/roil
src/console/simpleyui.js
function(content) { if (content) { if (content._node) { // map to DOMNode content = content._node; } else if (content._nodes) { // convert DOMNodeList to documentFragment content = Y_DOM._nl2frag(content._nodes); } } Y_DOM.addHTML(this._node, content, 'replace'); return this; }
javascript
function(content) { if (content) { if (content._node) { // map to DOMNode content = content._node; } else if (content._nodes) { // convert DOMNodeList to documentFragment content = Y_DOM._nl2frag(content._nodes); } } Y_DOM.addHTML(this._node, content, 'replace'); return this; }
[ "function", "(", "content", ")", "{", "if", "(", "content", ")", "{", "if", "(", "content", ".", "_node", ")", "{", "content", "=", "content", ".", "_node", ";", "}", "else", "if", "(", "content", ".", "_nodes", ")", "{", "content", "=", "Y_DOM", ".", "_nl2frag", "(", "content", ".", "_nodes", ")", ";", "}", "}", "Y_DOM", ".", "addHTML", "(", "this", ".", "_node", ",", "content", ",", "'replace'", ")", ";", "return", "this", ";", "}" ]
Replaces the node's current content with the content. @method setContent @param {String | Y.Node | HTMLElement} content The content to insert @chainable
[ "Replaces", "the", "node", "s", "current", "content", "with", "the", "content", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L11302-L11314
train
5long/roil
src/console/simpleyui.js
function(fn, context) { var instance = this; return Y.Array.some(this._nodes, function(node, index) { node = Y.one(node); context = context || node; return fn.call(context, node, index, instance); }); }
javascript
function(fn, context) { var instance = this; return Y.Array.some(this._nodes, function(node, index) { node = Y.one(node); context = context || node; return fn.call(context, node, index, instance); }); }
[ "function", "(", "fn", ",", "context", ")", "{", "var", "instance", "=", "this", ";", "return", "Y", ".", "Array", ".", "some", "(", "this", ".", "_nodes", ",", "function", "(", "node", ",", "index", ")", "{", "node", "=", "Y", ".", "one", "(", "node", ")", ";", "context", "=", "context", "||", "node", ";", "return", "fn", ".", "call", "(", "context", ",", "node", ",", "index", ",", "instance", ")", ";", "}", ")", ";", "}" ]
Executes the function once for each node until a true value is returned. @method some @param {Function} fn The function to apply. It receives 3 arguments: the current node instance, the node's index, and the NodeList instance @param {Object} context optional An optional context to execute the function from. Default context is the current Node instance @return {Boolean} Whether or not the function returned true for any node.
[ "Executes", "the", "function", "once", "for", "each", "node", "until", "a", "true", "value", "is", "returned", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L11586-L11593
train
5long/roil
src/console/simpleyui.js
function() { var doc, nodes = this._nodes, query = this._query, root = this._queryRoot; if (query) { if (!root) { if (nodes && nodes[0] && nodes[0].ownerDocument) { root = nodes[0].ownerDocument; } } this._nodes = Y.Selector.query(query, root); } return this; }
javascript
function() { var doc, nodes = this._nodes, query = this._query, root = this._queryRoot; if (query) { if (!root) { if (nodes && nodes[0] && nodes[0].ownerDocument) { root = nodes[0].ownerDocument; } } this._nodes = Y.Selector.query(query, root); } return this; }
[ "function", "(", ")", "{", "var", "doc", ",", "nodes", "=", "this", ".", "_nodes", ",", "query", "=", "this", ".", "_query", ",", "root", "=", "this", ".", "_queryRoot", ";", "if", "(", "query", ")", "{", "if", "(", "!", "root", ")", "{", "if", "(", "nodes", "&&", "nodes", "[", "0", "]", "&&", "nodes", "[", "0", "]", ".", "ownerDocument", ")", "{", "root", "=", "nodes", "[", "0", "]", ".", "ownerDocument", ";", "}", "}", "this", ".", "_nodes", "=", "Y", ".", "Selector", ".", "query", "(", "query", ",", "root", ")", ";", "}", "return", "this", ";", "}" ]
Reruns the initial query, when created using a selector query @method refresh @chainable
[ "Reruns", "the", "initial", "query", "when", "created", "using", "a", "selector", "query" ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L11676-L11693
train
5long/roil
src/console/simpleyui.js
function(type, fn, context) { return Y.on.apply(Y, this._prepEvtArgs.apply(this, arguments)); }
javascript
function(type, fn, context) { return Y.on.apply(Y, this._prepEvtArgs.apply(this, arguments)); }
[ "function", "(", "type", ",", "fn", ",", "context", ")", "{", "return", "Y", ".", "on", ".", "apply", "(", "Y", ",", "this", ".", "_prepEvtArgs", ".", "apply", "(", "this", ",", "arguments", ")", ")", ";", "}" ]
Applies an event listener to each Node bound to the NodeList. @method on @param {String} type The event being listened for @param {Function} fn The handler to call when the event fires @param {Object} context The context to call the handler with. Default is the NodeList instance. @return {Object} Returns an event handle that can later be use to detach(). @see Event.on
[ "Applies", "an", "event", "listener", "to", "each", "Node", "bound", "to", "the", "NodeList", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L11720-L11722
train
5long/roil
src/console/simpleyui.js
function (s,reviver) { // Replace certain Unicode characters that are otherwise handled // incorrectly by some browser implementations. // NOTE: This modifies the input if such characters are found! s = s.replace(_UNICODE_EXCEPTIONS, _escapeException); // Test for any remaining invalid characters if (!_UNSAFE.test(s.replace(_ESCAPES,'@'). replace(_VALUES,']'). replace(_BRACKETS,''))) { // Eval the text into a JavaScript data structure, apply any // reviver function, and return return _revive( _eval('(' + s + ')'), reviver ); } throw new SyntaxError('JSON.parse'); }
javascript
function (s,reviver) { // Replace certain Unicode characters that are otherwise handled // incorrectly by some browser implementations. // NOTE: This modifies the input if such characters are found! s = s.replace(_UNICODE_EXCEPTIONS, _escapeException); // Test for any remaining invalid characters if (!_UNSAFE.test(s.replace(_ESCAPES,'@'). replace(_VALUES,']'). replace(_BRACKETS,''))) { // Eval the text into a JavaScript data structure, apply any // reviver function, and return return _revive( _eval('(' + s + ')'), reviver ); } throw new SyntaxError('JSON.parse'); }
[ "function", "(", "s", ",", "reviver", ")", "{", "s", "=", "s", ".", "replace", "(", "_UNICODE_EXCEPTIONS", ",", "_escapeException", ")", ";", "if", "(", "!", "_UNSAFE", ".", "test", "(", "s", ".", "replace", "(", "_ESCAPES", ",", "'@'", ")", ".", "replace", "(", "_VALUES", ",", "']'", ")", ".", "replace", "(", "_BRACKETS", ",", "''", ")", ")", ")", "{", "return", "_revive", "(", "_eval", "(", "'('", "+", "s", "+", "')'", ")", ",", "reviver", ")", ";", "}", "throw", "new", "SyntaxError", "(", "'JSON.parse'", ")", ";", "}" ]
Alias to native browser implementation of the JSON object if available. @property Native @type {Object} @private
[ "Alias", "to", "native", "browser", "implementation", "of", "the", "JSON", "object", "if", "available", "." ]
37b14072a7aea17accc7f4e5e04dedc90a1358de
https://github.com/5long/roil/blob/37b14072a7aea17accc7f4e5e04dedc90a1358de/src/console/simpleyui.js#L13915-L13932
train
rsdoiel/tbone
depreciated/tbone_util.js
function (s) { return s.replace(re_NewLine, NewLine).replace(re_quot, quot).replace(re_apos, apos).replace(re_acute, acute).replace(re_sbquo, sbquo).replace(re_bdquo, bdquo).replace(re_hellip, hellip).replace(re_dagger, dagger).replace(re_Dagger, Dagger).replace(re_lsquo, lsquo).replace(re_rsquo, rsquo).replace(re_ldquo, ldquo).replace(re_rdquo, rdquo).replace(re_bull, bull).replace(re_ndash, ndash).replace(re_mdash, mdash).replace(re_copy, copyright_mark).replace(re_nbsp, nbsp).replace(re_laquo, laquo).replace(re_raquo, raquo); }
javascript
function (s) { return s.replace(re_NewLine, NewLine).replace(re_quot, quot).replace(re_apos, apos).replace(re_acute, acute).replace(re_sbquo, sbquo).replace(re_bdquo, bdquo).replace(re_hellip, hellip).replace(re_dagger, dagger).replace(re_Dagger, Dagger).replace(re_lsquo, lsquo).replace(re_rsquo, rsquo).replace(re_ldquo, ldquo).replace(re_rdquo, rdquo).replace(re_bull, bull).replace(re_ndash, ndash).replace(re_mdash, mdash).replace(re_copy, copyright_mark).replace(re_nbsp, nbsp).replace(re_laquo, laquo).replace(re_raquo, raquo); }
[ "function", "(", "s", ")", "{", "return", "s", ".", "replace", "(", "re_NewLine", ",", "NewLine", ")", ".", "replace", "(", "re_quot", ",", "quot", ")", ".", "replace", "(", "re_apos", ",", "apos", ")", ".", "replace", "(", "re_acute", ",", "acute", ")", ".", "replace", "(", "re_sbquo", ",", "sbquo", ")", ".", "replace", "(", "re_bdquo", ",", "bdquo", ")", ".", "replace", "(", "re_hellip", ",", "hellip", ")", ".", "replace", "(", "re_dagger", ",", "dagger", ")", ".", "replace", "(", "re_Dagger", ",", "Dagger", ")", ".", "replace", "(", "re_lsquo", ",", "lsquo", ")", ".", "replace", "(", "re_rsquo", ",", "rsquo", ")", ".", "replace", "(", "re_ldquo", ",", "ldquo", ")", ".", "replace", "(", "re_rdquo", ",", "rdquo", ")", ".", "replace", "(", "re_bull", ",", "bull", ")", ".", "replace", "(", "re_ndash", ",", "ndash", ")", ".", "replace", "(", "re_mdash", ",", "mdash", ")", ".", "replace", "(", "re_copy", ",", "copyright_mark", ")", ".", "replace", "(", "re_nbsp", ",", "nbsp", ")", ".", "replace", "(", "re_laquo", ",", "laquo", ")", ".", "replace", "(", "re_raquo", ",", "raquo", ")", ";", "}" ]
HTML_UTIL 5 entity and utility methods
[ "HTML_UTIL", "5", "entity", "and", "utility", "methods" ]
f05d2bba81d40f2b792a247dadce7d1a45342227
https://github.com/rsdoiel/tbone/blob/f05d2bba81d40f2b792a247dadce7d1a45342227/depreciated/tbone_util.js#L260-L262
train
kchapelier/migl-pool
src/pool.js
function (options) { poolId++; return new Pool( options.name ? options.name + ' (pool #' + poolId + ')' : 'pool #' + poolId, options.factory, options.initialize || noop, options.firstAllocationNumber || 20, options.allocationNumber || 1 ); }
javascript
function (options) { poolId++; return new Pool( options.name ? options.name + ' (pool #' + poolId + ')' : 'pool #' + poolId, options.factory, options.initialize || noop, options.firstAllocationNumber || 20, options.allocationNumber || 1 ); }
[ "function", "(", "options", ")", "{", "poolId", "++", ";", "return", "new", "Pool", "(", "options", ".", "name", "?", "options", ".", "name", "+", "' (pool #'", "+", "poolId", "+", "')'", ":", "'pool #'", "+", "poolId", ",", "options", ".", "factory", ",", "options", ".", "initialize", "||", "noop", ",", "options", ".", "firstAllocationNumber", "||", "20", ",", "options", ".", "allocationNumber", "||", "1", ")", ";", "}" ]
Create an object pool @param {Object} options Pool options (name, factory, initialize, firstAllocationNumber, allocationNumber) @returns {Pool} Instance of the object pool
[ "Create", "an", "object", "pool" ]
d8ee91d577d53df40cae34e9e6efa84abb9d5cfb
https://github.com/kchapelier/migl-pool/blob/d8ee91d577d53df40cae34e9e6efa84abb9d5cfb/src/pool.js#L105-L115
train
AndreasMadsen/immortal
lib/core/streams.js
RelayStream
function RelayStream(option) { Stream.apply(this, arguments); this.writable = true; this.readable = true; this.store = []; this.paused = !!option.paused; this.closed = false; }
javascript
function RelayStream(option) { Stream.apply(this, arguments); this.writable = true; this.readable = true; this.store = []; this.paused = !!option.paused; this.closed = false; }
[ "function", "RelayStream", "(", "option", ")", "{", "Stream", ".", "apply", "(", "this", ",", "arguments", ")", ";", "this", ".", "writable", "=", "true", ";", "this", ".", "readable", "=", "true", ";", "this", ".", "store", "=", "[", "]", ";", "this", ".", "paused", "=", "!", "!", "option", ".", "paused", ";", "this", ".", "closed", "=", "false", ";", "}" ]
This constructor will simply relay data by purpose this do not support .end or .close
[ "This", "constructor", "will", "simply", "relay", "data", "by", "purpose", "this", "do", "not", "support", ".", "end", "or", ".", "close" ]
c1ab5a4287a543fdfd980604a9e9927d663a9ef2
https://github.com/AndreasMadsen/immortal/blob/c1ab5a4287a543fdfd980604a9e9927d663a9ef2/lib/core/streams.js#L24-L32
train
redisjs/jsr-validate
lib/index.js
validate
function validate(cmd, args, info) { info = info || {}; var conf = info.conf || {} , authrequired = typeof conf.requirepass === 'string' , db = info.db , result; // handle quit command special case if(cmd === COMMANDS.QUIT) { // reply with an object that mimics succesful validation info.command = { cmd: cmd, args: args, def: Constants.MAP.quit, arity: true}; return info; // validate command is known }else{ info.command = validators.command(cmd, args, info); } // check args length (arity) info.command.arity = validators.arity(cmd, args, info); // handle authentication requests if(cmd === COMMANDS.AUTH) { info.conn.authenticated = validators.auth(cmd, args, info); // handle unauthenticated requests when auth is enabled }else if(authrequired && !info.conn.authenticated) { throw AuthRequired; } // check operation on the correct type of value // this validation extracts keys, looks up the values // to determine the type of the existing value // the val array (or null) is assigned to the command // info object so that calling code may re-use it and // save looking up keys and values again where necessary info.command.value = validators.type(cmd, args, info); return info; }
javascript
function validate(cmd, args, info) { info = info || {}; var conf = info.conf || {} , authrequired = typeof conf.requirepass === 'string' , db = info.db , result; // handle quit command special case if(cmd === COMMANDS.QUIT) { // reply with an object that mimics succesful validation info.command = { cmd: cmd, args: args, def: Constants.MAP.quit, arity: true}; return info; // validate command is known }else{ info.command = validators.command(cmd, args, info); } // check args length (arity) info.command.arity = validators.arity(cmd, args, info); // handle authentication requests if(cmd === COMMANDS.AUTH) { info.conn.authenticated = validators.auth(cmd, args, info); // handle unauthenticated requests when auth is enabled }else if(authrequired && !info.conn.authenticated) { throw AuthRequired; } // check operation on the correct type of value // this validation extracts keys, looks up the values // to determine the type of the existing value // the val array (or null) is assigned to the command // info object so that calling code may re-use it and // save looking up keys and values again where necessary info.command.value = validators.type(cmd, args, info); return info; }
[ "function", "validate", "(", "cmd", ",", "args", ",", "info", ")", "{", "info", "=", "info", "||", "{", "}", ";", "var", "conf", "=", "info", ".", "conf", "||", "{", "}", ",", "authrequired", "=", "typeof", "conf", ".", "requirepass", "===", "'string'", ",", "db", "=", "info", ".", "db", ",", "result", ";", "if", "(", "cmd", "===", "COMMANDS", ".", "QUIT", ")", "{", "info", ".", "command", "=", "{", "cmd", ":", "cmd", ",", "args", ":", "args", ",", "def", ":", "Constants", ".", "MAP", ".", "quit", ",", "arity", ":", "true", "}", ";", "return", "info", ";", "}", "else", "{", "info", ".", "command", "=", "validators", ".", "command", "(", "cmd", ",", "args", ",", "info", ")", ";", "}", "info", ".", "command", ".", "arity", "=", "validators", ".", "arity", "(", "cmd", ",", "args", ",", "info", ")", ";", "if", "(", "cmd", "===", "COMMANDS", ".", "AUTH", ")", "{", "info", ".", "conn", ".", "authenticated", "=", "validators", ".", "auth", "(", "cmd", ",", "args", ",", "info", ")", ";", "}", "else", "if", "(", "authrequired", "&&", "!", "info", ".", "conn", ".", "authenticated", ")", "{", "throw", "AuthRequired", ";", "}", "info", ".", "command", ".", "value", "=", "validators", ".", "type", "(", "cmd", ",", "args", ",", "info", ")", ";", "return", "info", ";", "}" ]
Performs complete validation for an incoming command. The command name should be lowercase. @param cmd The command name. @param args The command arguments. @param info The configuration and current database pointer.
[ "Performs", "complete", "validation", "for", "an", "incoming", "command", "." ]
2e0dddafb32c019ef9293a35b96cdd78dd8e4ae5
https://github.com/redisjs/jsr-validate/blob/2e0dddafb32c019ef9293a35b96cdd78dd8e4ae5/lib/index.js#L16-L55
train
adiwidjaja/frontend-pagebuilder
js/tinymce/plugins/spellchecker/plugin.js
indexOf
function indexOf(match) { var i = matches.length; while (i--) { if (matches[i] === match) { return i; } } return -1; }
javascript
function indexOf(match) { var i = matches.length; while (i--) { if (matches[i] === match) { return i; } } return -1; }
[ "function", "indexOf", "(", "match", ")", "{", "var", "i", "=", "matches", ".", "length", ";", "while", "(", "i", "--", ")", "{", "if", "(", "matches", "[", "i", "]", "===", "match", ")", "{", "return", "i", ";", "}", "}", "return", "-", "1", ";", "}" ]
Returns the index of a specific match object or -1 if it isn't found. @param {Match} match Text match object. @return {Number} Index of match or -1 if it isn't found.
[ "Returns", "the", "index", "of", "a", "specific", "match", "object", "or", "-", "1", "if", "it", "isn", "t", "found", "." ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/plugins/spellchecker/plugin.js#L356-L365
train
adiwidjaja/frontend-pagebuilder
js/tinymce/plugins/spellchecker/plugin.js
filter
function filter(callback) { var filteredMatches = []; each(function (match, i) { if (callback(match, i)) { filteredMatches.push(match); } }); matches = filteredMatches; /*jshint validthis:true*/ return this; }
javascript
function filter(callback) { var filteredMatches = []; each(function (match, i) { if (callback(match, i)) { filteredMatches.push(match); } }); matches = filteredMatches; /*jshint validthis:true*/ return this; }
[ "function", "filter", "(", "callback", ")", "{", "var", "filteredMatches", "=", "[", "]", ";", "each", "(", "function", "(", "match", ",", "i", ")", "{", "if", "(", "callback", "(", "match", ",", "i", ")", ")", "{", "filteredMatches", ".", "push", "(", "match", ")", ";", "}", "}", ")", ";", "matches", "=", "filteredMatches", ";", "return", "this", ";", "}" ]
Filters the matches. If the callback returns true it stays if not it gets removed. @param {Function} callback Callback to execute for each match. @return {DomTextMatcher} Current DomTextMatcher instance.
[ "Filters", "the", "matches", ".", "If", "the", "callback", "returns", "true", "it", "stays", "if", "not", "it", "gets", "removed", "." ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/plugins/spellchecker/plugin.js#L373-L386
train
adiwidjaja/frontend-pagebuilder
js/tinymce/plugins/spellchecker/plugin.js
each
function each(callback) { for (var i = 0, l = matches.length; i < l; i++) { if (callback(matches[i], i) === false) { break; } } /*jshint validthis:true*/ return this; }
javascript
function each(callback) { for (var i = 0, l = matches.length; i < l; i++) { if (callback(matches[i], i) === false) { break; } } /*jshint validthis:true*/ return this; }
[ "function", "each", "(", "callback", ")", "{", "for", "(", "var", "i", "=", "0", ",", "l", "=", "matches", ".", "length", ";", "i", "<", "l", ";", "i", "++", ")", "{", "if", "(", "callback", "(", "matches", "[", "i", "]", ",", "i", ")", "===", "false", ")", "{", "break", ";", "}", "}", "return", "this", ";", "}" ]
Executes the specified callback for each match. @param {Function} callback Callback to execute for each match. @return {DomTextMatcher} Current DomTextMatcher instance.
[ "Executes", "the", "specified", "callback", "for", "each", "match", "." ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/plugins/spellchecker/plugin.js#L394-L403
train
adiwidjaja/frontend-pagebuilder
js/tinymce/plugins/spellchecker/plugin.js
find
function find(regex, data) { if (text && regex.global) { while ((m = regex.exec(text))) { matches.push(createMatch(m, data)); } } return this; }
javascript
function find(regex, data) { if (text && regex.global) { while ((m = regex.exec(text))) { matches.push(createMatch(m, data)); } } return this; }
[ "function", "find", "(", "regex", ",", "data", ")", "{", "if", "(", "text", "&&", "regex", ".", "global", ")", "{", "while", "(", "(", "m", "=", "regex", ".", "exec", "(", "text", ")", ")", ")", "{", "matches", ".", "push", "(", "createMatch", "(", "m", ",", "data", ")", ")", ";", "}", "}", "return", "this", ";", "}" ]
Finds the specified regexp and adds them to the matches collection. @param {RegExp} regex Global regexp to search the current node by. @param {Object} [data] Optional custom data element for the match. @return {DomTextMatcher} Current DomTextMatcher instance.
[ "Finds", "the", "specified", "regexp", "and", "adds", "them", "to", "the", "matches", "collection", "." ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/plugins/spellchecker/plugin.js#L428-L436
train
adiwidjaja/frontend-pagebuilder
js/tinymce/plugins/spellchecker/plugin.js
unwrap
function unwrap(match) { var i, elements = getWrappersByIndex(match ? indexOf(match) : null); i = elements.length; while (i--) { unwrapElement(elements[i]); } return this; }
javascript
function unwrap(match) { var i, elements = getWrappersByIndex(match ? indexOf(match) : null); i = elements.length; while (i--) { unwrapElement(elements[i]); } return this; }
[ "function", "unwrap", "(", "match", ")", "{", "var", "i", ",", "elements", "=", "getWrappersByIndex", "(", "match", "?", "indexOf", "(", "match", ")", ":", "null", ")", ";", "i", "=", "elements", ".", "length", ";", "while", "(", "i", "--", ")", "{", "unwrapElement", "(", "elements", "[", "i", "]", ")", ";", "}", "return", "this", ";", "}" ]
Unwraps the specified match object or all matches if unspecified. @param {Object} [match] Optional match object. @return {DomTextMatcher} Current DomTextMatcher instance.
[ "Unwraps", "the", "specified", "match", "object", "or", "all", "matches", "if", "unspecified", "." ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/plugins/spellchecker/plugin.js#L444-L453
train
adiwidjaja/frontend-pagebuilder
js/tinymce/plugins/spellchecker/plugin.js
add
function add(start, length, data) { matches.push({ start: start, end: start + length, text: text.substr(start, length), data: data }); return this; }
javascript
function add(start, length, data) { matches.push({ start: start, end: start + length, text: text.substr(start, length), data: data }); return this; }
[ "function", "add", "(", "start", ",", "length", ",", "data", ")", "{", "matches", ".", "push", "(", "{", "start", ":", "start", ",", "end", ":", "start", "+", "length", ",", "text", ":", "text", ".", "substr", "(", "start", ",", "length", ")", ",", "data", ":", "data", "}", ")", ";", "return", "this", ";", "}" ]
Adds match the specified range for example a grammar line. @param {Number} start Start offset. @param {Number} length Length of the text. @param {Object} data Custom data object for match. @return {DomTextMatcher} Current DomTextMatcher instance.
[ "Adds", "match", "the", "specified", "range", "for", "example", "a", "grammar", "line", "." ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/plugins/spellchecker/plugin.js#L484-L493
train
adiwidjaja/frontend-pagebuilder
js/tinymce/plugins/spellchecker/plugin.js
rangeFromMatch
function rangeFromMatch(match) { var wrappers = getWrappersByIndex(indexOf(match)); var rng = editor.dom.createRng(); rng.setStartBefore(wrappers[0]); rng.setEndAfter(wrappers[wrappers.length - 1]); return rng; }
javascript
function rangeFromMatch(match) { var wrappers = getWrappersByIndex(indexOf(match)); var rng = editor.dom.createRng(); rng.setStartBefore(wrappers[0]); rng.setEndAfter(wrappers[wrappers.length - 1]); return rng; }
[ "function", "rangeFromMatch", "(", "match", ")", "{", "var", "wrappers", "=", "getWrappersByIndex", "(", "indexOf", "(", "match", ")", ")", ";", "var", "rng", "=", "editor", ".", "dom", ".", "createRng", "(", ")", ";", "rng", ".", "setStartBefore", "(", "wrappers", "[", "0", "]", ")", ";", "rng", ".", "setEndAfter", "(", "wrappers", "[", "wrappers", ".", "length", "-", "1", "]", ")", ";", "return", "rng", ";", "}" ]
Returns a DOM range for the specified match. @param {Object} match Match object to get range for. @return {DOMRange} DOM Range for the specified match.
[ "Returns", "a", "DOM", "range", "for", "the", "specified", "match", "." ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/plugins/spellchecker/plugin.js#L501-L509
train
adiwidjaja/frontend-pagebuilder
js/tinymce/plugins/spellchecker/plugin.js
replace
function replace(match, text) { var rng = rangeFromMatch(match); rng.deleteContents(); if (text.length > 0) { rng.insertNode(editor.dom.doc.createTextNode(text)); } return rng; }
javascript
function replace(match, text) { var rng = rangeFromMatch(match); rng.deleteContents(); if (text.length > 0) { rng.insertNode(editor.dom.doc.createTextNode(text)); } return rng; }
[ "function", "replace", "(", "match", ",", "text", ")", "{", "var", "rng", "=", "rangeFromMatch", "(", "match", ")", ";", "rng", ".", "deleteContents", "(", ")", ";", "if", "(", "text", ".", "length", ">", "0", ")", "{", "rng", ".", "insertNode", "(", "editor", ".", "dom", ".", "doc", ".", "createTextNode", "(", "text", ")", ")", ";", "}", "return", "rng", ";", "}" ]
Replaces the specified match with the specified text. @param {Object} match Match object to replace. @param {String} text Text to replace the match with. @return {DOMRange} DOM range produced after the replace.
[ "Replaces", "the", "specified", "match", "with", "the", "specified", "text", "." ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/plugins/spellchecker/plugin.js#L518-L528
train
adiwidjaja/frontend-pagebuilder
js/tinymce/plugins/spellchecker/plugin.js
markErrors
function markErrors(data) { var suggestions; if (data.words) { hasDictionarySupport = !!data.dictionary; suggestions = data.words; } else { // Fallback to old format suggestions = data; } editor.setProgressState(false); if (isEmpty(suggestions)) { var message = editor.translate('No misspellings found.'); editor.notificationManager.open({ text: message, type: 'info' }); started = false; return; } lastSuggestions = suggestions; getTextMatcher().find(getWordCharPattern()).filter(function (match) { return !!suggestions[match.text]; }).wrap(function (match) { return editor.dom.create('span', { "class": 'mce-spellchecker-word', "data-mce-bogus": 1, "data-mce-word": match.text }); }); started = true; editor.fire('SpellcheckStart'); }
javascript
function markErrors(data) { var suggestions; if (data.words) { hasDictionarySupport = !!data.dictionary; suggestions = data.words; } else { // Fallback to old format suggestions = data; } editor.setProgressState(false); if (isEmpty(suggestions)) { var message = editor.translate('No misspellings found.'); editor.notificationManager.open({ text: message, type: 'info' }); started = false; return; } lastSuggestions = suggestions; getTextMatcher().find(getWordCharPattern()).filter(function (match) { return !!suggestions[match.text]; }).wrap(function (match) { return editor.dom.create('span', { "class": 'mce-spellchecker-word', "data-mce-bogus": 1, "data-mce-word": match.text }); }); started = true; editor.fire('SpellcheckStart'); }
[ "function", "markErrors", "(", "data", ")", "{", "var", "suggestions", ";", "if", "(", "data", ".", "words", ")", "{", "hasDictionarySupport", "=", "!", "!", "data", ".", "dictionary", ";", "suggestions", "=", "data", ".", "words", ";", "}", "else", "{", "suggestions", "=", "data", ";", "}", "editor", ".", "setProgressState", "(", "false", ")", ";", "if", "(", "isEmpty", "(", "suggestions", ")", ")", "{", "var", "message", "=", "editor", ".", "translate", "(", "'No misspellings found.'", ")", ";", "editor", ".", "notificationManager", ".", "open", "(", "{", "text", ":", "message", ",", "type", ":", "'info'", "}", ")", ";", "started", "=", "false", ";", "return", ";", "}", "lastSuggestions", "=", "suggestions", ";", "getTextMatcher", "(", ")", ".", "find", "(", "getWordCharPattern", "(", ")", ")", ".", "filter", "(", "function", "(", "match", ")", "{", "return", "!", "!", "suggestions", "[", "match", ".", "text", "]", ";", "}", ")", ".", "wrap", "(", "function", "(", "match", ")", "{", "return", "editor", ".", "dom", ".", "create", "(", "'span'", ",", "{", "\"class\"", ":", "'mce-spellchecker-word'", ",", "\"data-mce-bogus\"", ":", "1", ",", "\"data-mce-word\"", ":", "match", ".", "text", "}", ")", ";", "}", ")", ";", "started", "=", "true", ";", "editor", ".", "fire", "(", "'SpellcheckStart'", ")", ";", "}" ]
Find the specified words and marks them. It will also show suggestions for those words. @example editor.plugins.spellchecker.markErrors({ dictionary: true, words: { "word1": ["suggestion 1", "Suggestion 2"] } }); @param {Object} data Data object containing the words with suggestions.
[ "Find", "the", "specified", "words", "and", "marks", "them", ".", "It", "will", "also", "show", "suggestions", "for", "those", "words", "." ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/plugins/spellchecker/plugin.js#L1075-L1109
train
skerit/alchemy-styleboost
public/ckeditor/4.4dev/core/htmlparser/element.js
function( filter, context ) { var element = this, originalName, name; context = element.getFilterContext( context ); // Do not process elements with data-cke-processor attribute set to off. if ( context.off ) return true; // Filtering if it's the root node. if ( !element.parent ) filter.onRoot( context, element ); while ( true ) { originalName = element.name; if ( !( name = filter.onElementName( context, originalName ) ) ) { this.remove(); return false; } element.name = name; if ( !( element = filter.onElement( context, element ) ) ) { this.remove(); return false; } // New element has been returned - replace current one // and process it (stop processing this and return false, what // means that element has been removed). if ( element !== this ) { this.replaceWith( element ); return false; } // If name has been changed - continue loop, so in next iteration // filters for new name will be applied to this element. // If name hasn't been changed - stop. if ( element.name == originalName ) break; // If element has been replaced with something of a // different type, then make the replacement filter itself. if ( element.type != CKEDITOR.NODE_ELEMENT ) { this.replaceWith( element ); return false; } // This indicate that the element has been dropped by // filter but not the children. if ( !element.name ) { this.replaceWithChildren(); return false; } } var attributes = element.attributes, a, value, newAttrName; for ( a in attributes ) { newAttrName = a; value = attributes[ a ]; // Loop until name isn't modified. // A little bit senseless, but IE would do that anyway // because it iterates with for-in loop even over properties // created during its run. while ( true ) { if ( !( newAttrName = filter.onAttributeName( context, a ) ) ) { delete attributes[ a ]; break; } else if ( newAttrName != a ) { delete attributes[ a ]; a = newAttrName; continue; } else { break; } } if ( newAttrName ) { if ( ( value = filter.onAttribute( context, element, newAttrName, value ) ) === false ) delete attributes[ newAttrName ]; else attributes[ newAttrName ] = value; } } if ( !element.isEmpty ) this.filterChildren( filter, false, context ); return true; }
javascript
function( filter, context ) { var element = this, originalName, name; context = element.getFilterContext( context ); // Do not process elements with data-cke-processor attribute set to off. if ( context.off ) return true; // Filtering if it's the root node. if ( !element.parent ) filter.onRoot( context, element ); while ( true ) { originalName = element.name; if ( !( name = filter.onElementName( context, originalName ) ) ) { this.remove(); return false; } element.name = name; if ( !( element = filter.onElement( context, element ) ) ) { this.remove(); return false; } // New element has been returned - replace current one // and process it (stop processing this and return false, what // means that element has been removed). if ( element !== this ) { this.replaceWith( element ); return false; } // If name has been changed - continue loop, so in next iteration // filters for new name will be applied to this element. // If name hasn't been changed - stop. if ( element.name == originalName ) break; // If element has been replaced with something of a // different type, then make the replacement filter itself. if ( element.type != CKEDITOR.NODE_ELEMENT ) { this.replaceWith( element ); return false; } // This indicate that the element has been dropped by // filter but not the children. if ( !element.name ) { this.replaceWithChildren(); return false; } } var attributes = element.attributes, a, value, newAttrName; for ( a in attributes ) { newAttrName = a; value = attributes[ a ]; // Loop until name isn't modified. // A little bit senseless, but IE would do that anyway // because it iterates with for-in loop even over properties // created during its run. while ( true ) { if ( !( newAttrName = filter.onAttributeName( context, a ) ) ) { delete attributes[ a ]; break; } else if ( newAttrName != a ) { delete attributes[ a ]; a = newAttrName; continue; } else { break; } } if ( newAttrName ) { if ( ( value = filter.onAttribute( context, element, newAttrName, value ) ) === false ) delete attributes[ newAttrName ]; else attributes[ newAttrName ] = value; } } if ( !element.isEmpty ) this.filterChildren( filter, false, context ); return true; }
[ "function", "(", "filter", ",", "context", ")", "{", "var", "element", "=", "this", ",", "originalName", ",", "name", ";", "context", "=", "element", ".", "getFilterContext", "(", "context", ")", ";", "if", "(", "context", ".", "off", ")", "return", "true", ";", "if", "(", "!", "element", ".", "parent", ")", "filter", ".", "onRoot", "(", "context", ",", "element", ")", ";", "while", "(", "true", ")", "{", "originalName", "=", "element", ".", "name", ";", "if", "(", "!", "(", "name", "=", "filter", ".", "onElementName", "(", "context", ",", "originalName", ")", ")", ")", "{", "this", ".", "remove", "(", ")", ";", "return", "false", ";", "}", "element", ".", "name", "=", "name", ";", "if", "(", "!", "(", "element", "=", "filter", ".", "onElement", "(", "context", ",", "element", ")", ")", ")", "{", "this", ".", "remove", "(", ")", ";", "return", "false", ";", "}", "if", "(", "element", "!==", "this", ")", "{", "this", ".", "replaceWith", "(", "element", ")", ";", "return", "false", ";", "}", "if", "(", "element", ".", "name", "==", "originalName", ")", "break", ";", "if", "(", "element", ".", "type", "!=", "CKEDITOR", ".", "NODE_ELEMENT", ")", "{", "this", ".", "replaceWith", "(", "element", ")", ";", "return", "false", ";", "}", "if", "(", "!", "element", ".", "name", ")", "{", "this", ".", "replaceWithChildren", "(", ")", ";", "return", "false", ";", "}", "}", "var", "attributes", "=", "element", ".", "attributes", ",", "a", ",", "value", ",", "newAttrName", ";", "for", "(", "a", "in", "attributes", ")", "{", "newAttrName", "=", "a", ";", "value", "=", "attributes", "[", "a", "]", ";", "while", "(", "true", ")", "{", "if", "(", "!", "(", "newAttrName", "=", "filter", ".", "onAttributeName", "(", "context", ",", "a", ")", ")", ")", "{", "delete", "attributes", "[", "a", "]", ";", "break", ";", "}", "else", "if", "(", "newAttrName", "!=", "a", ")", "{", "delete", "attributes", "[", "a", "]", ";", "a", "=", "newAttrName", ";", "continue", ";", "}", "else", "{", "break", ";", "}", "}", "if", "(", "newAttrName", ")", "{", "if", "(", "(", "value", "=", "filter", ".", "onAttribute", "(", "context", ",", "element", ",", "newAttrName", ",", "value", ")", ")", "===", "false", ")", "delete", "attributes", "[", "newAttrName", "]", ";", "else", "attributes", "[", "newAttrName", "]", "=", "value", ";", "}", "}", "if", "(", "!", "element", ".", "isEmpty", ")", "this", ".", "filterChildren", "(", "filter", ",", "false", ",", "context", ")", ";", "return", "true", ";", "}" ]
Filters this element and its children with the given filter. @since 4.1 @param {CKEDITOR.htmlParser.filter} filter @returns {Boolean} The method returns `false` when this element has been removed or replaced with another. This information means that {@link #filterChildren} has to repeat the filter on the current position in parent's children array.
[ "Filters", "this", "element", "and", "its", "children", "with", "the", "given", "filter", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/htmlparser/element.js#L160-L254
train
skerit/alchemy-styleboost
public/ckeditor/4.4dev/core/htmlparser/element.js
function( writer, filter ) { if ( filter ) this.filter( filter ); var name = this.name, attribsArray = [], attributes = this.attributes, attrName, attr, i, l; // Open element tag. writer.openTag( name, attributes ); // Copy all attributes to an array. for ( attrName in attributes ) attribsArray.push( [ attrName, attributes[ attrName ] ] ); // Sort the attributes by name. if ( writer.sortAttributes ) attribsArray.sort( sortAttribs ); // Send the attributes. for ( i = 0, l = attribsArray.length; i < l; i++ ) { attr = attribsArray[ i ]; writer.attribute( attr[ 0 ], attr[ 1 ] ); } // Close the tag. writer.openTagClose( name, this.isEmpty ); this.writeChildrenHtml( writer ); // Close the element. if ( !this.isEmpty ) writer.closeTag( name ); }
javascript
function( writer, filter ) { if ( filter ) this.filter( filter ); var name = this.name, attribsArray = [], attributes = this.attributes, attrName, attr, i, l; // Open element tag. writer.openTag( name, attributes ); // Copy all attributes to an array. for ( attrName in attributes ) attribsArray.push( [ attrName, attributes[ attrName ] ] ); // Sort the attributes by name. if ( writer.sortAttributes ) attribsArray.sort( sortAttribs ); // Send the attributes. for ( i = 0, l = attribsArray.length; i < l; i++ ) { attr = attribsArray[ i ]; writer.attribute( attr[ 0 ], attr[ 1 ] ); } // Close the tag. writer.openTagClose( name, this.isEmpty ); this.writeChildrenHtml( writer ); // Close the element. if ( !this.isEmpty ) writer.closeTag( name ); }
[ "function", "(", "writer", ",", "filter", ")", "{", "if", "(", "filter", ")", "this", ".", "filter", "(", "filter", ")", ";", "var", "name", "=", "this", ".", "name", ",", "attribsArray", "=", "[", "]", ",", "attributes", "=", "this", ".", "attributes", ",", "attrName", ",", "attr", ",", "i", ",", "l", ";", "writer", ".", "openTag", "(", "name", ",", "attributes", ")", ";", "for", "(", "attrName", "in", "attributes", ")", "attribsArray", ".", "push", "(", "[", "attrName", ",", "attributes", "[", "attrName", "]", "]", ")", ";", "if", "(", "writer", ".", "sortAttributes", ")", "attribsArray", ".", "sort", "(", "sortAttribs", ")", ";", "for", "(", "i", "=", "0", ",", "l", "=", "attribsArray", ".", "length", ";", "i", "<", "l", ";", "i", "++", ")", "{", "attr", "=", "attribsArray", "[", "i", "]", ";", "writer", ".", "attribute", "(", "attr", "[", "0", "]", ",", "attr", "[", "1", "]", ")", ";", "}", "writer", ".", "openTagClose", "(", "name", ",", "this", ".", "isEmpty", ")", ";", "this", ".", "writeChildrenHtml", "(", "writer", ")", ";", "if", "(", "!", "this", ".", "isEmpty", ")", "writer", ".", "closeTag", "(", "name", ")", ";", "}" ]
Writes the element HTML to the CKEDITOR.htmlWriter. @param {CKEDITOR.htmlParser.basicWriter} writer The writer to which HTML will be written. @param {CKEDITOR.htmlParser.filter} [filter] The filter to be applied to this node. **Note:** It is unsafe to filter an offline (not appended) node.
[ "Writes", "the", "element", "HTML", "to", "the", "CKEDITOR", ".", "htmlWriter", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/htmlparser/element.js#L274-L309
train
skerit/alchemy-styleboost
public/ckeditor/4.4dev/core/htmlparser/element.js
function() { var children = this.children; for ( var i = children.length; i; ) children[ --i ].insertAfter( this ); this.remove(); }
javascript
function() { var children = this.children; for ( var i = children.length; i; ) children[ --i ].insertAfter( this ); this.remove(); }
[ "function", "(", ")", "{", "var", "children", "=", "this", ".", "children", ";", "for", "(", "var", "i", "=", "children", ".", "length", ";", "i", ";", ")", "children", "[", "--", "i", "]", ".", "insertAfter", "(", "this", ")", ";", "this", ".", "remove", "(", ")", ";", "}" ]
Replaces this element with its children. @since 4.1
[ "Replaces", "this", "element", "with", "its", "children", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/htmlparser/element.js#L324-L331
train
skerit/alchemy-styleboost
public/ckeditor/4.4dev/core/htmlparser/element.js
function( condition ) { if ( !condition ) return this.children.length ? this.children[ 0 ] : null; if ( typeof condition != 'function' ) condition = nameCondition( condition ); for ( var i = 0, l = this.children.length; i < l; ++i ) { if ( condition( this.children[ i ] ) ) return this.children[ i ]; } return null; }
javascript
function( condition ) { if ( !condition ) return this.children.length ? this.children[ 0 ] : null; if ( typeof condition != 'function' ) condition = nameCondition( condition ); for ( var i = 0, l = this.children.length; i < l; ++i ) { if ( condition( this.children[ i ] ) ) return this.children[ i ]; } return null; }
[ "function", "(", "condition", ")", "{", "if", "(", "!", "condition", ")", "return", "this", ".", "children", ".", "length", "?", "this", ".", "children", "[", "0", "]", ":", "null", ";", "if", "(", "typeof", "condition", "!=", "'function'", ")", "condition", "=", "nameCondition", "(", "condition", ")", ";", "for", "(", "var", "i", "=", "0", ",", "l", "=", "this", ".", "children", ".", "length", ";", "i", "<", "l", ";", "++", "i", ")", "{", "if", "(", "condition", "(", "this", ".", "children", "[", "i", "]", ")", ")", "return", "this", ".", "children", "[", "i", "]", ";", "}", "return", "null", ";", "}" ]
Gets this element's first child. If `condition` is given, this method returns the first child which satisfies that condition. @since 4.3 @param {String/Object/Function} condition Name of a child, a hash of names, or a validator function. @returns {CKEDITOR.htmlParser.node}
[ "Gets", "this", "element", "s", "first", "child", ".", "If", "condition", "is", "given", "this", "method", "returns", "the", "first", "child", "which", "satisfies", "that", "condition", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/htmlparser/element.js#L366-L378
train
skerit/alchemy-styleboost
public/ckeditor/4.4dev/core/htmlparser/element.js
function( html ) { var children = this.children = CKEDITOR.htmlParser.fragment.fromHtml( html ).children; for ( var i = 0, l = children.length; i < l; ++i ) children[ i ].parent = this; }
javascript
function( html ) { var children = this.children = CKEDITOR.htmlParser.fragment.fromHtml( html ).children; for ( var i = 0, l = children.length; i < l; ++i ) children[ i ].parent = this; }
[ "function", "(", "html", ")", "{", "var", "children", "=", "this", ".", "children", "=", "CKEDITOR", ".", "htmlParser", ".", "fragment", ".", "fromHtml", "(", "html", ")", ".", "children", ";", "for", "(", "var", "i", "=", "0", ",", "l", "=", "children", ".", "length", ";", "i", "<", "l", ";", "++", "i", ")", "children", "[", "i", "]", ".", "parent", "=", "this", ";", "}" ]
Sets this element's inner HTML. @since 4.3 @param {String} html
[ "Sets", "this", "element", "s", "inner", "HTML", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/htmlparser/element.js#L398-L403
train
skerit/alchemy-styleboost
public/ckeditor/4.4dev/core/htmlparser/element.js
function( index ) { var cloneChildren = this.children.splice( index, this.children.length - index ), clone = this.clone(); for ( var i = 0; i < cloneChildren.length; ++i ) cloneChildren[ i ].parent = clone; clone.children = cloneChildren; if ( cloneChildren[ 0 ] ) cloneChildren[ 0 ].previous = null; if ( index > 0 ) this.children[ index - 1 ].next = null; this.parent.add( clone, this.getIndex() + 1 ); return clone; }
javascript
function( index ) { var cloneChildren = this.children.splice( index, this.children.length - index ), clone = this.clone(); for ( var i = 0; i < cloneChildren.length; ++i ) cloneChildren[ i ].parent = clone; clone.children = cloneChildren; if ( cloneChildren[ 0 ] ) cloneChildren[ 0 ].previous = null; if ( index > 0 ) this.children[ index - 1 ].next = null; this.parent.add( clone, this.getIndex() + 1 ); return clone; }
[ "function", "(", "index", ")", "{", "var", "cloneChildren", "=", "this", ".", "children", ".", "splice", "(", "index", ",", "this", ".", "children", ".", "length", "-", "index", ")", ",", "clone", "=", "this", ".", "clone", "(", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "cloneChildren", ".", "length", ";", "++", "i", ")", "cloneChildren", "[", "i", "]", ".", "parent", "=", "clone", ";", "clone", ".", "children", "=", "cloneChildren", ";", "if", "(", "cloneChildren", "[", "0", "]", ")", "cloneChildren", "[", "0", "]", ".", "previous", "=", "null", ";", "if", "(", "index", ">", "0", ")", "this", ".", "children", "[", "index", "-", "1", "]", ".", "next", "=", "null", ";", "this", ".", "parent", ".", "add", "(", "clone", ",", "this", ".", "getIndex", "(", ")", "+", "1", ")", ";", "return", "clone", ";", "}" ]
Splits this element at the given index. @since 4.3 @param {Number} index Index at which the element will be split &mdash; `0` means the beginning, `1` after first child node, etc. @returns {CKEDITOR.htmlParser.element} The new element following this one.
[ "Splits", "this", "element", "at", "the", "given", "index", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/htmlparser/element.js#L425-L443
train
skerit/alchemy-styleboost
public/ckeditor/4.4dev/core/htmlparser/element.js
function( className ) { var classes = this.attributes[ 'class' ]; if ( !classes ) return; // We can safely assume that className won't break regexp. // http://stackoverflow.com/questions/448981/what-characters-are-valid-in-css-class-names classes = CKEDITOR.tools.trim( classes.replace( new RegExp( '(?:\\s+|^)' + className + '(?:\\s+|$)' ), ' ' ) ); if ( classes ) this.attributes[ 'class' ] = classes; else delete this.attributes[ 'class' ]; }
javascript
function( className ) { var classes = this.attributes[ 'class' ]; if ( !classes ) return; // We can safely assume that className won't break regexp. // http://stackoverflow.com/questions/448981/what-characters-are-valid-in-css-class-names classes = CKEDITOR.tools.trim( classes.replace( new RegExp( '(?:\\s+|^)' + className + '(?:\\s+|$)' ), ' ' ) ); if ( classes ) this.attributes[ 'class' ] = classes; else delete this.attributes[ 'class' ]; }
[ "function", "(", "className", ")", "{", "var", "classes", "=", "this", ".", "attributes", "[", "'class'", "]", ";", "if", "(", "!", "classes", ")", "return", ";", "classes", "=", "CKEDITOR", ".", "tools", ".", "trim", "(", "classes", ".", "replace", "(", "new", "RegExp", "(", "'(?:\\\\s+|^)'", "+", "\\\\", "+", "className", ")", ",", "'(?:\\\\s+|$)'", ")", ")", ";", "\\\\", "}" ]
Removes a class name from the list of classes. @since 4.3 @param {String} className The class name to be removed.
[ "Removes", "a", "class", "name", "from", "the", "list", "of", "classes", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/htmlparser/element.js#L466-L480
train
mcccclean/node-gamesprites
lib/formatters.js
function(outname, imagedata) { var frames = []; var animations = {}; // first pass: set up frame for each image, ensure an animation array is present imagedata.forEach(function(im) { var ox = Math.floor(im.width / 2); var oy = Math.floor(im.height / 2); im.frame = frames.length; frames.push([im.x, im.y, im.width, im.height, 0, im.ox, im.oy]); if(!animations[im.animname]) { animations[im.animname] = { frames: [] }; } }); // re-sort the images to frame order and then push their frame indices // into the respective arrays. imagedata.sort(function(a, b) { return a.animidx - b.animidx; }); imagedata.forEach(function(im) { animations[im.animname].frames.push(im.frame); }); // put all the data in its appropriate groups and JSONify var data = { frames: frames, animations: animations, images: [ outname + ".png" ] }; return JSON.stringify(data, null, 2); }
javascript
function(outname, imagedata) { var frames = []; var animations = {}; // first pass: set up frame for each image, ensure an animation array is present imagedata.forEach(function(im) { var ox = Math.floor(im.width / 2); var oy = Math.floor(im.height / 2); im.frame = frames.length; frames.push([im.x, im.y, im.width, im.height, 0, im.ox, im.oy]); if(!animations[im.animname]) { animations[im.animname] = { frames: [] }; } }); // re-sort the images to frame order and then push their frame indices // into the respective arrays. imagedata.sort(function(a, b) { return a.animidx - b.animidx; }); imagedata.forEach(function(im) { animations[im.animname].frames.push(im.frame); }); // put all the data in its appropriate groups and JSONify var data = { frames: frames, animations: animations, images: [ outname + ".png" ] }; return JSON.stringify(data, null, 2); }
[ "function", "(", "outname", ",", "imagedata", ")", "{", "var", "frames", "=", "[", "]", ";", "var", "animations", "=", "{", "}", ";", "imagedata", ".", "forEach", "(", "function", "(", "im", ")", "{", "var", "ox", "=", "Math", ".", "floor", "(", "im", ".", "width", "/", "2", ")", ";", "var", "oy", "=", "Math", ".", "floor", "(", "im", ".", "height", "/", "2", ")", ";", "im", ".", "frame", "=", "frames", ".", "length", ";", "frames", ".", "push", "(", "[", "im", ".", "x", ",", "im", ".", "y", ",", "im", ".", "width", ",", "im", ".", "height", ",", "0", ",", "im", ".", "ox", ",", "im", ".", "oy", "]", ")", ";", "if", "(", "!", "animations", "[", "im", ".", "animname", "]", ")", "{", "animations", "[", "im", ".", "animname", "]", "=", "{", "frames", ":", "[", "]", "}", ";", "}", "}", ")", ";", "imagedata", ".", "sort", "(", "function", "(", "a", ",", "b", ")", "{", "return", "a", ".", "animidx", "-", "b", ".", "animidx", ";", "}", ")", ";", "imagedata", ".", "forEach", "(", "function", "(", "im", ")", "{", "animations", "[", "im", ".", "animname", "]", ".", "frames", ".", "push", "(", "im", ".", "frame", ")", ";", "}", ")", ";", "var", "data", "=", "{", "frames", ":", "frames", ",", "animations", ":", "animations", ",", "images", ":", "[", "outname", "+", "\".png\"", "]", "}", ";", "return", "JSON", ".", "stringify", "(", "data", ",", "null", ",", "2", ")", ";", "}" ]
format for CreateJS framework
[ "format", "for", "CreateJS", "framework" ]
9c430065cda394c82f8074b7bf6b07ff807c1431
https://github.com/mcccclean/node-gamesprites/blob/9c430065cda394c82f8074b7bf6b07ff807c1431/lib/formatters.js#L4-L33
train
the-simian/phaser-shim-loader
index.js
phaserShim
function phaserShim(source) { this.cacheable && this.cacheable(); source = source .replace(/"object"==typeof exports/, 'false') .replace(/(var\s+\w+\s*=\s*)Phaser(\s*\|\|\s*\{)/, 'var PIXI = exports.PIXI; $1Phaser$2') .replace(/typeof module !== 'undefined' && module\.exports/g, "false /* typeof module !== 'undefined' && module.exports */") .replace(/require\('nw\.gui'\)/g, "undefined /* require('nw.gui') */") .replace(/(p2\.Body\.prototype)/, 'var Phaser = require("Phaser").Phaser; var p2 = require("p2"); $1'); source = 'var document = global.document;\n\n' + source; return source; }
javascript
function phaserShim(source) { this.cacheable && this.cacheable(); source = source .replace(/"object"==typeof exports/, 'false') .replace(/(var\s+\w+\s*=\s*)Phaser(\s*\|\|\s*\{)/, 'var PIXI = exports.PIXI; $1Phaser$2') .replace(/typeof module !== 'undefined' && module\.exports/g, "false /* typeof module !== 'undefined' && module.exports */") .replace(/require\('nw\.gui'\)/g, "undefined /* require('nw.gui') */") .replace(/(p2\.Body\.prototype)/, 'var Phaser = require("Phaser").Phaser; var p2 = require("p2"); $1'); source = 'var document = global.document;\n\n' + source; return source; }
[ "function", "phaserShim", "(", "source", ")", "{", "this", ".", "cacheable", "&&", "this", ".", "cacheable", "(", ")", ";", "source", "=", "source", ".", "replace", "(", "/", "\"object\"==typeof exports", "/", ",", "'false'", ")", ".", "replace", "(", "/", "(var\\s+\\w+\\s*=\\s*)Phaser(\\s*\\|\\|\\s*\\{)", "/", ",", "'var PIXI = exports.PIXI; $1Phaser$2'", ")", ".", "replace", "(", "/", "typeof module !== 'undefined' && module\\.exports", "/", "g", ",", "\"false /* typeof module !== 'undefined' && module.exports */\"", ")", ".", "replace", "(", "/", "require\\('nw\\.gui'\\)", "/", "g", ",", "\"undefined /* require('nw.gui') */\"", ")", ".", "replace", "(", "/", "(p2\\.Body\\.prototype)", "/", ",", "'var Phaser = require(\"Phaser\").Phaser; var p2 = require(\"p2\"); $1'", ")", ";", "source", "=", "'var document = global.document;\\n\\n'", "+", "\\n", ";", "\\n", "}" ]
phaser-webpack-loader
[ "phaser", "-", "webpack", "-", "loader" ]
ff22b8903de18d6d9eff1765722366892daf929a
https://github.com/the-simian/phaser-shim-loader/blob/ff22b8903de18d6d9eff1765722366892daf929a/index.js#L5-L18
train
SilentCicero/ethdeploy-provider-zero-client
index.js
function(providerObject) { const fixedProviderObject = Object.assign({}, providerObject); const oldGetAccountsMethod = providerObject.getAccounts; // fix get accounts if (typeof fixedProviderObject.getAccounts !== 'undefined') { fixedProviderObject.getAccounts = function(getAccountsCallback) { const oldCallback = getAccountsCallback; // build fixed callback with lowercased accounts const fixedCallback = function(accountsError, accountsResult) { const fixedAccountsResult = accountsResult.slice(0); // if no error, fixed result if (!accountsError) { fixedAccountsResult.map(function(item) { return String(item.toLowerCase()); }); } // fire oldd callback with new fix oldCallback(accountsError, fixedAccountsResult); } // fire get accounts method oldGetAccountsMethod(fixedCallback); }; } // return fixed provider object return fixedProviderObject; }
javascript
function(providerObject) { const fixedProviderObject = Object.assign({}, providerObject); const oldGetAccountsMethod = providerObject.getAccounts; // fix get accounts if (typeof fixedProviderObject.getAccounts !== 'undefined') { fixedProviderObject.getAccounts = function(getAccountsCallback) { const oldCallback = getAccountsCallback; // build fixed callback with lowercased accounts const fixedCallback = function(accountsError, accountsResult) { const fixedAccountsResult = accountsResult.slice(0); // if no error, fixed result if (!accountsError) { fixedAccountsResult.map(function(item) { return String(item.toLowerCase()); }); } // fire oldd callback with new fix oldCallback(accountsError, fixedAccountsResult); } // fire get accounts method oldGetAccountsMethod(fixedCallback); }; } // return fixed provider object return fixedProviderObject; }
[ "function", "(", "providerObject", ")", "{", "const", "fixedProviderObject", "=", "Object", ".", "assign", "(", "{", "}", ",", "providerObject", ")", ";", "const", "oldGetAccountsMethod", "=", "providerObject", ".", "getAccounts", ";", "if", "(", "typeof", "fixedProviderObject", ".", "getAccounts", "!==", "'undefined'", ")", "{", "fixedProviderObject", ".", "getAccounts", "=", "function", "(", "getAccountsCallback", ")", "{", "const", "oldCallback", "=", "getAccountsCallback", ";", "const", "fixedCallback", "=", "function", "(", "accountsError", ",", "accountsResult", ")", "{", "const", "fixedAccountsResult", "=", "accountsResult", ".", "slice", "(", "0", ")", ";", "if", "(", "!", "accountsError", ")", "{", "fixedAccountsResult", ".", "map", "(", "function", "(", "item", ")", "{", "return", "String", "(", "item", ".", "toLowerCase", "(", ")", ")", ";", "}", ")", ";", "}", "oldCallback", "(", "accountsError", ",", "fixedAccountsResult", ")", ";", "}", "oldGetAccountsMethod", "(", "fixedCallback", ")", ";", "}", ";", "}", "return", "fixedProviderObject", ";", "}" ]
fix getAccounts method
[ "fix", "getAccounts", "method" ]
d0b777c47cd5fa61fa3cae5055ecb29a16b95f84
https://github.com/SilentCicero/ethdeploy-provider-zero-client/blob/d0b777c47cd5fa61fa3cae5055ecb29a16b95f84/index.js#L6-L37
train
SilentCicero/ethdeploy-provider-zero-client
index.js
function(accountsError, accountsResult) { const fixedAccountsResult = accountsResult.slice(0); // if no error, fixed result if (!accountsError) { fixedAccountsResult.map(function(item) { return String(item.toLowerCase()); }); } // fire oldd callback with new fix oldCallback(accountsError, fixedAccountsResult); }
javascript
function(accountsError, accountsResult) { const fixedAccountsResult = accountsResult.slice(0); // if no error, fixed result if (!accountsError) { fixedAccountsResult.map(function(item) { return String(item.toLowerCase()); }); } // fire oldd callback with new fix oldCallback(accountsError, fixedAccountsResult); }
[ "function", "(", "accountsError", ",", "accountsResult", ")", "{", "const", "fixedAccountsResult", "=", "accountsResult", ".", "slice", "(", "0", ")", ";", "if", "(", "!", "accountsError", ")", "{", "fixedAccountsResult", ".", "map", "(", "function", "(", "item", ")", "{", "return", "String", "(", "item", ".", "toLowerCase", "(", ")", ")", ";", "}", ")", ";", "}", "oldCallback", "(", "accountsError", ",", "fixedAccountsResult", ")", ";", "}" ]
build fixed callback with lowercased accounts
[ "build", "fixed", "callback", "with", "lowercased", "accounts" ]
d0b777c47cd5fa61fa3cae5055ecb29a16b95f84
https://github.com/SilentCicero/ethdeploy-provider-zero-client/blob/d0b777c47cd5fa61fa3cae5055ecb29a16b95f84/index.js#L16-L28
train
SilentCicero/ethdeploy-provider-zero-client
index.js
function(rawTx) { const rawTxMutation = Object.assign({}, rawTx); // fix rawTx gaslimit if (typeof rawTxMutation.gas !== 'undefined') { rawTxMutation.gasLimit = rawTxMutation.gas; delete rawTxMutation.gas; } // fix data by prefixing it with zero if (typeof rawTxMutation.data !== 'undefined' && rawTxMutation.data.slice(0, 2) !== '0x') { rawTxMutation.data = '0x' + rawTxMutation.data; } // return new mutated raw tx object return rawTxMutation; }
javascript
function(rawTx) { const rawTxMutation = Object.assign({}, rawTx); // fix rawTx gaslimit if (typeof rawTxMutation.gas !== 'undefined') { rawTxMutation.gasLimit = rawTxMutation.gas; delete rawTxMutation.gas; } // fix data by prefixing it with zero if (typeof rawTxMutation.data !== 'undefined' && rawTxMutation.data.slice(0, 2) !== '0x') { rawTxMutation.data = '0x' + rawTxMutation.data; } // return new mutated raw tx object return rawTxMutation; }
[ "function", "(", "rawTx", ")", "{", "const", "rawTxMutation", "=", "Object", ".", "assign", "(", "{", "}", ",", "rawTx", ")", ";", "if", "(", "typeof", "rawTxMutation", ".", "gas", "!==", "'undefined'", ")", "{", "rawTxMutation", ".", "gasLimit", "=", "rawTxMutation", ".", "gas", ";", "delete", "rawTxMutation", ".", "gas", ";", "}", "if", "(", "typeof", "rawTxMutation", ".", "data", "!==", "'undefined'", "&&", "rawTxMutation", ".", "data", ".", "slice", "(", "0", ",", "2", ")", "!==", "'0x'", ")", "{", "rawTxMutation", ".", "data", "=", "'0x'", "+", "rawTxMutation", ".", "data", ";", "}", "return", "rawTxMutation", ";", "}" ]
fix ethereumjs-tx rawTx object
[ "fix", "ethereumjs", "-", "tx", "rawTx", "object" ]
d0b777c47cd5fa61fa3cae5055ecb29a16b95f84
https://github.com/SilentCicero/ethdeploy-provider-zero-client/blob/d0b777c47cd5fa61fa3cae5055ecb29a16b95f84/index.js#L40-L57
train
SilentCicero/ethdeploy-provider-zero-client
index.js
function(providerObject) { const fixedProviderObject = Object.assign({}, providerObject); // object has signTransaction if (typeof fixedProviderObject.signTransaction !== 'undefined') { // store old sign transaction method const oldSignTransactionMethod = fixedProviderObject.signTransaction; // build new provider object signTransaciton method fixedProviderObject.signTransaction = function(rawTx, cb) { // fire old callback oldSignTransactionMethod(fixEthereumJSTxObject(rawTx), cb); }; } // return fixed provider object return fixedProviderObject; }
javascript
function(providerObject) { const fixedProviderObject = Object.assign({}, providerObject); // object has signTransaction if (typeof fixedProviderObject.signTransaction !== 'undefined') { // store old sign transaction method const oldSignTransactionMethod = fixedProviderObject.signTransaction; // build new provider object signTransaciton method fixedProviderObject.signTransaction = function(rawTx, cb) { // fire old callback oldSignTransactionMethod(fixEthereumJSTxObject(rawTx), cb); }; } // return fixed provider object return fixedProviderObject; }
[ "function", "(", "providerObject", ")", "{", "const", "fixedProviderObject", "=", "Object", ".", "assign", "(", "{", "}", ",", "providerObject", ")", ";", "if", "(", "typeof", "fixedProviderObject", ".", "signTransaction", "!==", "'undefined'", ")", "{", "const", "oldSignTransactionMethod", "=", "fixedProviderObject", ".", "signTransaction", ";", "fixedProviderObject", ".", "signTransaction", "=", "function", "(", "rawTx", ",", "cb", ")", "{", "oldSignTransactionMethod", "(", "fixEthereumJSTxObject", "(", "rawTx", ")", ",", "cb", ")", ";", "}", ";", "}", "return", "fixedProviderObject", ";", "}" ]
fix signTransaction method with rawTx fix
[ "fix", "signTransaction", "method", "with", "rawTx", "fix" ]
d0b777c47cd5fa61fa3cae5055ecb29a16b95f84
https://github.com/SilentCicero/ethdeploy-provider-zero-client/blob/d0b777c47cd5fa61fa3cae5055ecb29a16b95f84/index.js#L60-L77
train
Qwerios/madlib-xmldom
lib/browser.js
function(xmlString) { var error, parser, xmlDoc; if ((typeof Ti !== "undefined" && Ti !== null) && Ti.XML) { try { xmlDoc = Ti.XML.parseString(xmlString); } catch (_error) { error = _error; xmlDoc = null; } return xmlDoc; } else if (window.DOMParser != null) { try { parser = new window.DOMParser(); xmlDoc = parser.parseFromString(xmlString, "text/xml"); } catch (_error) { error = _error; xmlDoc = null; } return xmlDoc; } else if (window.ActiveXObject && window.GetObject) { xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async = "false"; try { xmlDoc.loadXML(xmlString); } catch (_error) { error = _error; xmlDoc = null; } return xmlDoc; } else { throw new Error("No XML parser available"); } }
javascript
function(xmlString) { var error, parser, xmlDoc; if ((typeof Ti !== "undefined" && Ti !== null) && Ti.XML) { try { xmlDoc = Ti.XML.parseString(xmlString); } catch (_error) { error = _error; xmlDoc = null; } return xmlDoc; } else if (window.DOMParser != null) { try { parser = new window.DOMParser(); xmlDoc = parser.parseFromString(xmlString, "text/xml"); } catch (_error) { error = _error; xmlDoc = null; } return xmlDoc; } else if (window.ActiveXObject && window.GetObject) { xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async = "false"; try { xmlDoc.loadXML(xmlString); } catch (_error) { error = _error; xmlDoc = null; } return xmlDoc; } else { throw new Error("No XML parser available"); } }
[ "function", "(", "xmlString", ")", "{", "var", "error", ",", "parser", ",", "xmlDoc", ";", "if", "(", "(", "typeof", "Ti", "!==", "\"undefined\"", "&&", "Ti", "!==", "null", ")", "&&", "Ti", ".", "XML", ")", "{", "try", "{", "xmlDoc", "=", "Ti", ".", "XML", ".", "parseString", "(", "xmlString", ")", ";", "}", "catch", "(", "_error", ")", "{", "error", "=", "_error", ";", "xmlDoc", "=", "null", ";", "}", "return", "xmlDoc", ";", "}", "else", "if", "(", "window", ".", "DOMParser", "!=", "null", ")", "{", "try", "{", "parser", "=", "new", "window", ".", "DOMParser", "(", ")", ";", "xmlDoc", "=", "parser", ".", "parseFromString", "(", "xmlString", ",", "\"text/xml\"", ")", ";", "}", "catch", "(", "_error", ")", "{", "error", "=", "_error", ";", "xmlDoc", "=", "null", ";", "}", "return", "xmlDoc", ";", "}", "else", "if", "(", "window", ".", "ActiveXObject", "&&", "window", ".", "GetObject", ")", "{", "xmlDoc", "=", "new", "ActiveXObject", "(", "\"Microsoft.XMLDOM\"", ")", ";", "xmlDoc", ".", "async", "=", "\"false\"", ";", "try", "{", "xmlDoc", ".", "loadXML", "(", "xmlString", ")", ";", "}", "catch", "(", "_error", ")", "{", "error", "=", "_error", ";", "xmlDoc", "=", "null", ";", "}", "return", "xmlDoc", ";", "}", "else", "{", "throw", "new", "Error", "(", "\"No XML parser available\"", ")", ";", "}", "}" ]
Turns the provided XML string into an XML DOM Document using whatever native means of doing so is available @function parse @param {String} xmlString A valid string containing XML @return {DOM} An XML DOM Document instance
[ "Turns", "the", "provided", "XML", "string", "into", "an", "XML", "DOM", "Document", "using", "whatever", "native", "means", "of", "doing", "so", "is", "available" ]
e1bed72403519830c1e0255f2faa774ffecbed3d
https://github.com/Qwerios/madlib-xmldom/blob/e1bed72403519830c1e0255f2faa774ffecbed3d/lib/browser.js#L30-L62
train
Qwerios/madlib-xmldom
lib/browser.js
function(xmlNode) { var noNativeXml, noXMLSerializer; if ((typeof Ti !== "undefined" && Ti !== null) && Ti.XML) { return Ti.XML.serializeToString(xmlNode); } else { try { return (new XMLSerializer()).serializeToString(xmlNode); } catch (_error) { noXMLSerializer = _error; try { return xmlNode.xml; } catch (_error) { noNativeXml = _error; throw new Error("No XML serialization support"); } } } }
javascript
function(xmlNode) { var noNativeXml, noXMLSerializer; if ((typeof Ti !== "undefined" && Ti !== null) && Ti.XML) { return Ti.XML.serializeToString(xmlNode); } else { try { return (new XMLSerializer()).serializeToString(xmlNode); } catch (_error) { noXMLSerializer = _error; try { return xmlNode.xml; } catch (_error) { noNativeXml = _error; throw new Error("No XML serialization support"); } } } }
[ "function", "(", "xmlNode", ")", "{", "var", "noNativeXml", ",", "noXMLSerializer", ";", "if", "(", "(", "typeof", "Ti", "!==", "\"undefined\"", "&&", "Ti", "!==", "null", ")", "&&", "Ti", ".", "XML", ")", "{", "return", "Ti", ".", "XML", ".", "serializeToString", "(", "xmlNode", ")", ";", "}", "else", "{", "try", "{", "return", "(", "new", "XMLSerializer", "(", ")", ")", ".", "serializeToString", "(", "xmlNode", ")", ";", "}", "catch", "(", "_error", ")", "{", "noXMLSerializer", "=", "_error", ";", "try", "{", "return", "xmlNode", ".", "xml", ";", "}", "catch", "(", "_error", ")", "{", "noNativeXml", "=", "_error", ";", "throw", "new", "Error", "(", "\"No XML serialization support\"", ")", ";", "}", "}", "}", "}" ]
Turns the provided XML DOM Node into an XML string using whatever native means of doing so is available @function serialize @param {DOM Node} The XML Node that is to be serialized @return {String} An XML string representation of the node and its children
[ "Turns", "the", "provided", "XML", "DOM", "Node", "into", "an", "XML", "string", "using", "whatever", "native", "means", "of", "doing", "so", "is", "available" ]
e1bed72403519830c1e0255f2faa774ffecbed3d
https://github.com/Qwerios/madlib-xmldom/blob/e1bed72403519830c1e0255f2faa774ffecbed3d/lib/browser.js#L74-L91
train
nomocas/yamvish
lib/context.js
function(space, type, path, value, index) { // console.log('context.notifyUpstream : ', space, type, path, value, index); for (var i = 0, len = space._upstreams.length; i < len; ++i) { var upstream = space._upstreams[i]; if (!upstream) { // maybe it's because upstreams length has change so update it // (probably a (or more) previous listener has removed some listeners through cascade) len = space._upstreams.length; continue; } // path is local to notified node. value is the modified value. index is the one from modification point. upstream.call(this, value, type, path, index); } }
javascript
function(space, type, path, value, index) { // console.log('context.notifyUpstream : ', space, type, path, value, index); for (var i = 0, len = space._upstreams.length; i < len; ++i) { var upstream = space._upstreams[i]; if (!upstream) { // maybe it's because upstreams length has change so update it // (probably a (or more) previous listener has removed some listeners through cascade) len = space._upstreams.length; continue; } // path is local to notified node. value is the modified value. index is the one from modification point. upstream.call(this, value, type, path, index); } }
[ "function", "(", "space", ",", "type", ",", "path", ",", "value", ",", "index", ")", "{", "for", "(", "var", "i", "=", "0", ",", "len", "=", "space", ".", "_upstreams", ".", "length", ";", "i", "<", "len", ";", "++", "i", ")", "{", "var", "upstream", "=", "space", ".", "_upstreams", "[", "i", "]", ";", "if", "(", "!", "upstream", ")", "{", "len", "=", "space", ".", "_upstreams", ".", "length", ";", "continue", ";", "}", "upstream", ".", "call", "(", "this", ",", "value", ",", "type", ",", "path", ",", "index", ")", ";", "}", "}" ]
notification from root to modification point. Normaly for internal use.
[ "notification", "from", "root", "to", "modification", "point", ".", "Normaly", "for", "internal", "use", "." ]
017a536bb6bafddf1b31c0c7af6f723be58e9f0e
https://github.com/nomocas/yamvish/blob/017a536bb6bafddf1b31c0c7af6f723be58e9f0e/lib/context.js#L433-L446
train
b3nsn0w/murmur-random
index.js
random
function random (seed) { /** * Creates a subgenerator from the current one * * @param {string} key Key of the subgenerator * @param {...number} params Parameters affecting the subgenerator's seed */ function subgen (key, ...params) { return random(createSeed([...seed, keygen(key), ...params], seed.length)) } /** * Retrieves a value from the random generator * * **Warning:** keys are cached indefinitely, keep them constant * * @param {string} key Key of the random value * @param {...number} params Parameters affecting the value */ function value (key, ...params) { return murmur([...seed, keygen(key), ...params]) } return { seed, subgen, value, util } }
javascript
function random (seed) { /** * Creates a subgenerator from the current one * * @param {string} key Key of the subgenerator * @param {...number} params Parameters affecting the subgenerator's seed */ function subgen (key, ...params) { return random(createSeed([...seed, keygen(key), ...params], seed.length)) } /** * Retrieves a value from the random generator * * **Warning:** keys are cached indefinitely, keep them constant * * @param {string} key Key of the random value * @param {...number} params Parameters affecting the value */ function value (key, ...params) { return murmur([...seed, keygen(key), ...params]) } return { seed, subgen, value, util } }
[ "function", "random", "(", "seed", ")", "{", "function", "subgen", "(", "key", ",", "...", "params", ")", "{", "return", "random", "(", "createSeed", "(", "[", "...", "seed", ",", "keygen", "(", "key", ")", ",", "...", "params", "]", ",", "seed", ".", "length", ")", ")", "}", "function", "value", "(", "key", ",", "...", "params", ")", "{", "return", "murmur", "(", "[", "...", "seed", ",", "keygen", "(", "key", ")", ",", "...", "params", "]", ")", "}", "return", "{", "seed", ",", "subgen", ",", "value", ",", "util", "}", "}" ]
Creates a deterministic random generator @param {...number} seed Raw seed of the random generator
[ "Creates", "a", "deterministic", "random", "generator" ]
240977106f74fc20583ef0c4f95aaf862a8b3bdc
https://github.com/b3nsn0w/murmur-random/blob/240977106f74fc20583ef0c4f95aaf862a8b3bdc/index.js#L17-L43
train