id
int32
0
58k
repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
46,700
alexindigo/deeply
adapters/array.js
arrayAdapter
function arrayAdapter(to, from, merge) { // reset target array to.splice(0); // transfer actual values from.reduce(function(target, value, index) { // use `undefined` as always-override value target[index] = merge(undefined, value); return target; }, to); return to; }
javascript
function arrayAdapter(to, from, merge) { // reset target array to.splice(0); // transfer actual values from.reduce(function(target, value, index) { // use `undefined` as always-override value target[index] = merge(undefined, value); return target; }, to); return to; }
[ "function", "arrayAdapter", "(", "to", ",", "from", ",", "merge", ")", "{", "// reset target array", "to", ".", "splice", "(", "0", ")", ";", "// transfer actual values", "from", ".", "reduce", "(", "function", "(", "target", ",", "value", ",", "index", ")", "{", "// use `undefined` as always-override value", "target", "[", "index", "]", "=", "merge", "(", "undefined", ",", "value", ")", ";", "return", "target", ";", "}", ",", "to", ")", ";", "return", "to", ";", "}" ]
Adapter to merge arrays Note: resets target value @param {array} to - target array to update @param {array} from - array to clone @param {function} merge - iterator to merge sub elements @returns {array} - modified target object
[ "Adapter", "to", "merge", "arrays" ]
d9f59eec37b75ce52038b3fcfb0fd86d4989c0c1
https://github.com/alexindigo/deeply/blob/d9f59eec37b75ce52038b3fcfb0fd86d4989c0c1/adapters/array.js#L14-L29
46,701
pford68/aspectjs
index.js
weave
function weave(type, advised, advisedFunc, aopProxy) { let f, $execute, standalone = false, transfer = aopProxy.transfer, adviser = aopProxy.adviser; if (!advisedFunc) { standalone = true; $execute = advised; } else { $execute = advised[advisedFunc].bind(advised); } aopProxy.advised = $execute; switch(type){ case 'before': f = function () { let result = adviser.apply(advised, arguments); // Invoke the advice. result = result && !transfer ? [result] : null; return $execute.apply(advised, result || arguments); // Call the original function. }; break; case 'after': f = function () { let result = $execute.apply(advised, arguments); // Call the original function and store the result. result = result && !transfer ? [result] : null; return adviser.apply(advised, result || arguments); // Invoke the advice. }; break; case 'around': let invocation = { proceed: function () { return this.method.apply(this, this.args); } }; f = function () { invocation.args = arguments; invocation.method = $execute; invocation.name = advisedFunc; return adviser(invocation); }; break; default: console.log("AOP Error", "Unsupported advice type: " + type); } if (standalone) { return (advised = f); } else { return (advised[advisedFunc] = f); } }
javascript
function weave(type, advised, advisedFunc, aopProxy) { let f, $execute, standalone = false, transfer = aopProxy.transfer, adviser = aopProxy.adviser; if (!advisedFunc) { standalone = true; $execute = advised; } else { $execute = advised[advisedFunc].bind(advised); } aopProxy.advised = $execute; switch(type){ case 'before': f = function () { let result = adviser.apply(advised, arguments); // Invoke the advice. result = result && !transfer ? [result] : null; return $execute.apply(advised, result || arguments); // Call the original function. }; break; case 'after': f = function () { let result = $execute.apply(advised, arguments); // Call the original function and store the result. result = result && !transfer ? [result] : null; return adviser.apply(advised, result || arguments); // Invoke the advice. }; break; case 'around': let invocation = { proceed: function () { return this.method.apply(this, this.args); } }; f = function () { invocation.args = arguments; invocation.method = $execute; invocation.name = advisedFunc; return adviser(invocation); }; break; default: console.log("AOP Error", "Unsupported advice type: " + type); } if (standalone) { return (advised = f); } else { return (advised[advisedFunc] = f); } }
[ "function", "weave", "(", "type", ",", "advised", ",", "advisedFunc", ",", "aopProxy", ")", "{", "let", "f", ",", "$execute", ",", "standalone", "=", "false", ",", "transfer", "=", "aopProxy", ".", "transfer", ",", "adviser", "=", "aopProxy", ".", "adviser", ";", "if", "(", "!", "advisedFunc", ")", "{", "standalone", "=", "true", ";", "$execute", "=", "advised", ";", "}", "else", "{", "$execute", "=", "advised", "[", "advisedFunc", "]", ".", "bind", "(", "advised", ")", ";", "}", "aopProxy", ".", "advised", "=", "$execute", ";", "switch", "(", "type", ")", "{", "case", "'before'", ":", "f", "=", "function", "(", ")", "{", "let", "result", "=", "adviser", ".", "apply", "(", "advised", ",", "arguments", ")", ";", "// Invoke the advice.", "result", "=", "result", "&&", "!", "transfer", "?", "[", "result", "]", ":", "null", ";", "return", "$execute", ".", "apply", "(", "advised", ",", "result", "||", "arguments", ")", ";", "// Call the original function.", "}", ";", "break", ";", "case", "'after'", ":", "f", "=", "function", "(", ")", "{", "let", "result", "=", "$execute", ".", "apply", "(", "advised", ",", "arguments", ")", ";", "// Call the original function and store the result.", "result", "=", "result", "&&", "!", "transfer", "?", "[", "result", "]", ":", "null", ";", "return", "adviser", ".", "apply", "(", "advised", ",", "result", "||", "arguments", ")", ";", "// Invoke the advice.", "}", ";", "break", ";", "case", "'around'", ":", "let", "invocation", "=", "{", "proceed", ":", "function", "(", ")", "{", "return", "this", ".", "method", ".", "apply", "(", "this", ",", "this", ".", "args", ")", ";", "}", "}", ";", "f", "=", "function", "(", ")", "{", "invocation", ".", "args", "=", "arguments", ";", "invocation", ".", "method", "=", "$execute", ";", "invocation", ".", "name", "=", "advisedFunc", ";", "return", "adviser", "(", "invocation", ")", ";", "}", ";", "break", ";", "default", ":", "console", ".", "log", "(", "\"AOP Error\"", ",", "\"Unsupported advice type: \"", "+", "type", ")", ";", "}", "if", "(", "standalone", ")", "{", "return", "(", "advised", "=", "f", ")", ";", "}", "else", "{", "return", "(", "advised", "[", "advisedFunc", "]", "=", "f", ")", ";", "}", "}" ]
A simple AOP implementation for JavaScript @author Philip Ford
[ "A", "simple", "AOP", "implementation", "for", "JavaScript" ]
7e2a78d2e45ffd33ea736d5f171191121075a73a
https://github.com/pford68/aspectjs/blob/7e2a78d2e45ffd33ea736d5f171191121075a73a/index.js#L7-L58
46,702
bvalosek/sticky
util/identityTransform.js
identityTranform
function identityTranform(idSelector) { idSelector = idSelector || function(x) { return x.id; }; var identityMap = {}; return function(input, output, instance) { var id; // Swap out the instance we are populating in the output transform chain if // we have a cached version of it, otherwise this will be the cached // instance. if (output) { id = idSelector(output); if (!id) return; if (identityMap[id]) { instance = identityMap[id]; return instance; } else { identityMap[id] = instance; } // For input, first time we see a model, cache the instance if it has an // id. Also make sure that if our input instance has an id that its the // same identity as what we have cached. } else { id = idSelector(instance); if (!id) return; if (!identityMap[id]) identityMap[id] = instance; else if (identityMap[id] !== instance) throw new Error('Incorrect identity for model id ' + id); } }; }
javascript
function identityTranform(idSelector) { idSelector = idSelector || function(x) { return x.id; }; var identityMap = {}; return function(input, output, instance) { var id; // Swap out the instance we are populating in the output transform chain if // we have a cached version of it, otherwise this will be the cached // instance. if (output) { id = idSelector(output); if (!id) return; if (identityMap[id]) { instance = identityMap[id]; return instance; } else { identityMap[id] = instance; } // For input, first time we see a model, cache the instance if it has an // id. Also make sure that if our input instance has an id that its the // same identity as what we have cached. } else { id = idSelector(instance); if (!id) return; if (!identityMap[id]) identityMap[id] = instance; else if (identityMap[id] !== instance) throw new Error('Incorrect identity for model id ' + id); } }; }
[ "function", "identityTranform", "(", "idSelector", ")", "{", "idSelector", "=", "idSelector", "||", "function", "(", "x", ")", "{", "return", "x", ".", "id", ";", "}", ";", "var", "identityMap", "=", "{", "}", ";", "return", "function", "(", "input", ",", "output", ",", "instance", ")", "{", "var", "id", ";", "// Swap out the instance we are populating in the output transform chain if", "// we have a cached version of it, otherwise this will be the cached", "// instance.", "if", "(", "output", ")", "{", "id", "=", "idSelector", "(", "output", ")", ";", "if", "(", "!", "id", ")", "return", ";", "if", "(", "identityMap", "[", "id", "]", ")", "{", "instance", "=", "identityMap", "[", "id", "]", ";", "return", "instance", ";", "}", "else", "{", "identityMap", "[", "id", "]", "=", "instance", ";", "}", "// For input, first time we see a model, cache the instance if it has an", "// id. Also make sure that if our input instance has an id that its the", "// same identity as what we have cached.", "}", "else", "{", "id", "=", "idSelector", "(", "instance", ")", ";", "if", "(", "!", "id", ")", "return", ";", "if", "(", "!", "identityMap", "[", "id", "]", ")", "identityMap", "[", "id", "]", "=", "instance", ";", "else", "if", "(", "identityMap", "[", "id", "]", "!==", "instance", ")", "throw", "new", "Error", "(", "'Incorrect identity for model id '", "+", "id", ")", ";", "}", "}", ";", "}" ]
A stick tranform that keeps in internal hash of all returned objects to ensure that identity is maintained. This is leaky as hell. @param {function(item: any): string} idSelector
[ "A", "stick", "tranform", "that", "keeps", "in", "internal", "hash", "of", "all", "returned", "objects", "to", "ensure", "that", "identity", "is", "maintained", ".", "This", "is", "leaky", "as", "hell", "." ]
8cb5fdba05be161e5936f7208558bc4702aae59a
https://github.com/bvalosek/sticky/blob/8cb5fdba05be161e5936f7208558bc4702aae59a/util/identityTransform.js#L8-L42
46,703
jtangelder/faketouches.js
faketouches.js
FakeTouches
function FakeTouches(element) { this.element = element; this.touches = []; this.touch_type = FakeTouches.TOUCH_EVENTS; this.has_multitouch = true; }
javascript
function FakeTouches(element) { this.element = element; this.touches = []; this.touch_type = FakeTouches.TOUCH_EVENTS; this.has_multitouch = true; }
[ "function", "FakeTouches", "(", "element", ")", "{", "this", ".", "element", "=", "element", ";", "this", ".", "touches", "=", "[", "]", ";", "this", ".", "touch_type", "=", "FakeTouches", ".", "TOUCH_EVENTS", ";", "this", ".", "has_multitouch", "=", "true", ";", "}" ]
create faketouches instance @param element @constructor
[ "create", "faketouches", "instance" ]
6d45de08109018a768bf1e3822a4bf63fd230564
https://github.com/jtangelder/faketouches.js/blob/6d45de08109018a768bf1e3822a4bf63fd230564/faketouches.js#L13-L19
46,704
jtangelder/faketouches.js
faketouches.js
triggerTouch
function triggerTouch(type) { var event = document.createEvent('Event'); var touchlist = this._createTouchList(this.touches); event.initEvent('touch' + type, true, true); event.touches = touchlist; event.changedTouches = touchlist; return this.element.dispatchEvent(event); }
javascript
function triggerTouch(type) { var event = document.createEvent('Event'); var touchlist = this._createTouchList(this.touches); event.initEvent('touch' + type, true, true); event.touches = touchlist; event.changedTouches = touchlist; return this.element.dispatchEvent(event); }
[ "function", "triggerTouch", "(", "type", ")", "{", "var", "event", "=", "document", ".", "createEvent", "(", "'Event'", ")", ";", "var", "touchlist", "=", "this", ".", "_createTouchList", "(", "this", ".", "touches", ")", ";", "event", ".", "initEvent", "(", "'touch'", "+", "type", ",", "true", ",", "true", ")", ";", "event", ".", "touches", "=", "touchlist", ";", "event", ".", "changedTouches", "=", "touchlist", ";", "return", "this", ".", "element", ".", "dispatchEvent", "(", "event", ")", ";", "}" ]
trigger touch event @param type @returns {Boolean}
[ "trigger", "touch", "event" ]
6d45de08109018a768bf1e3822a4bf63fd230564
https://github.com/jtangelder/faketouches.js/blob/6d45de08109018a768bf1e3822a4bf63fd230564/faketouches.js#L175-L184
46,705
jtangelder/faketouches.js
faketouches.js
triggerMouse
function triggerMouse(type) { var names = { start: 'mousedown', move: 'mousemove', end: 'mouseup' }; var event = document.createEvent('Event'); event.initEvent(names[type], true, true); var touchList = this._createTouchList(this.touches); if(touchList[0]) { event.pageX = touchList[0].pageX; event.pageY = touchList[0].pageY; event.clientX = touchList[0].clientX; event.clientY = touchList[0].clientY; event.button = 0; } return this.element.dispatchEvent(event); }
javascript
function triggerMouse(type) { var names = { start: 'mousedown', move: 'mousemove', end: 'mouseup' }; var event = document.createEvent('Event'); event.initEvent(names[type], true, true); var touchList = this._createTouchList(this.touches); if(touchList[0]) { event.pageX = touchList[0].pageX; event.pageY = touchList[0].pageY; event.clientX = touchList[0].clientX; event.clientY = touchList[0].clientY; event.button = 0; } return this.element.dispatchEvent(event); }
[ "function", "triggerMouse", "(", "type", ")", "{", "var", "names", "=", "{", "start", ":", "'mousedown'", ",", "move", ":", "'mousemove'", ",", "end", ":", "'mouseup'", "}", ";", "var", "event", "=", "document", ".", "createEvent", "(", "'Event'", ")", ";", "event", ".", "initEvent", "(", "names", "[", "type", "]", ",", "true", ",", "true", ")", ";", "var", "touchList", "=", "this", ".", "_createTouchList", "(", "this", ".", "touches", ")", ";", "if", "(", "touchList", "[", "0", "]", ")", "{", "event", ".", "pageX", "=", "touchList", "[", "0", "]", ".", "pageX", ";", "event", ".", "pageY", "=", "touchList", "[", "0", "]", ".", "pageY", ";", "event", ".", "clientX", "=", "touchList", "[", "0", "]", ".", "clientX", ";", "event", ".", "clientY", "=", "touchList", "[", "0", "]", ".", "clientY", ";", "event", ".", "button", "=", "0", ";", "}", "return", "this", ".", "element", ".", "dispatchEvent", "(", "event", ")", ";", "}" ]
trigger mouse event @param type @returns {Boolean}
[ "trigger", "mouse", "event" ]
6d45de08109018a768bf1e3822a4bf63fd230564
https://github.com/jtangelder/faketouches.js/blob/6d45de08109018a768bf1e3822a4bf63fd230564/faketouches.js#L191-L209
46,706
jtangelder/faketouches.js
faketouches.js
triggerPointerEvents
function triggerPointerEvents(type, pointerType) { var self = this; var names = { start: 'MSPointerDown', move: 'MSPointerMove', end: 'MSPointerUp' }; var touchList = this._createTouchList(this.touches); touchList.forEach(function(touch) { var event = document.createEvent('Event'); event.initEvent(names[type], true, true); event.MSPOINTER_TYPE_MOUSE = FakeTouches.POINTER_TYPE_MOUSE; event.MSPOINTER_TYPE_TOUCH = FakeTouches.POINTER_TYPE_TOUCH; event.MSPOINTER_TYPE_PEN = FakeTouches.POINTER_TYPE_PEN; event.pointerId = touch.identifier; event.pointerType = pointerType; event.pageX = touch.pageX; event.pageY = touch.pageY; event.clientX = touch.clientX; event.clientY = touch.clientY; event.buttons = (type == 'end') ? 0 : 1; self.element.dispatchEvent(event); }); return true; }
javascript
function triggerPointerEvents(type, pointerType) { var self = this; var names = { start: 'MSPointerDown', move: 'MSPointerMove', end: 'MSPointerUp' }; var touchList = this._createTouchList(this.touches); touchList.forEach(function(touch) { var event = document.createEvent('Event'); event.initEvent(names[type], true, true); event.MSPOINTER_TYPE_MOUSE = FakeTouches.POINTER_TYPE_MOUSE; event.MSPOINTER_TYPE_TOUCH = FakeTouches.POINTER_TYPE_TOUCH; event.MSPOINTER_TYPE_PEN = FakeTouches.POINTER_TYPE_PEN; event.pointerId = touch.identifier; event.pointerType = pointerType; event.pageX = touch.pageX; event.pageY = touch.pageY; event.clientX = touch.clientX; event.clientY = touch.clientY; event.buttons = (type == 'end') ? 0 : 1; self.element.dispatchEvent(event); }); return true; }
[ "function", "triggerPointerEvents", "(", "type", ",", "pointerType", ")", "{", "var", "self", "=", "this", ";", "var", "names", "=", "{", "start", ":", "'MSPointerDown'", ",", "move", ":", "'MSPointerMove'", ",", "end", ":", "'MSPointerUp'", "}", ";", "var", "touchList", "=", "this", ".", "_createTouchList", "(", "this", ".", "touches", ")", ";", "touchList", ".", "forEach", "(", "function", "(", "touch", ")", "{", "var", "event", "=", "document", ".", "createEvent", "(", "'Event'", ")", ";", "event", ".", "initEvent", "(", "names", "[", "type", "]", ",", "true", ",", "true", ")", ";", "event", ".", "MSPOINTER_TYPE_MOUSE", "=", "FakeTouches", ".", "POINTER_TYPE_MOUSE", ";", "event", ".", "MSPOINTER_TYPE_TOUCH", "=", "FakeTouches", ".", "POINTER_TYPE_TOUCH", ";", "event", ".", "MSPOINTER_TYPE_PEN", "=", "FakeTouches", ".", "POINTER_TYPE_PEN", ";", "event", ".", "pointerId", "=", "touch", ".", "identifier", ";", "event", ".", "pointerType", "=", "pointerType", ";", "event", ".", "pageX", "=", "touch", ".", "pageX", ";", "event", ".", "pageY", "=", "touch", ".", "pageY", ";", "event", ".", "clientX", "=", "touch", ".", "clientX", ";", "event", ".", "clientY", "=", "touch", ".", "clientY", ";", "event", ".", "buttons", "=", "(", "type", "==", "'end'", ")", "?", "0", ":", "1", ";", "self", ".", "element", ".", "dispatchEvent", "(", "event", ")", ";", "}", ")", ";", "return", "true", ";", "}" ]
trigger pointer event @param type @param pointerType @returns {Boolean}
[ "trigger", "pointer", "event" ]
6d45de08109018a768bf1e3822a4bf63fd230564
https://github.com/jtangelder/faketouches.js/blob/6d45de08109018a768bf1e3822a4bf63fd230564/faketouches.js#L217-L246
46,707
arve0/metalsmith-pandoc
index.js
plugin
function plugin(options){ options = options || {}; var from = options.from || 'markdown'; var to = options.to || 'html5'; var args = options.args || []; var opts = options.opts || {}; var pattern = options.pattern || '**/*.md'; var extension = options.ext || '.html'; if (to === 'docx' || to === 'pdf') { opts.encoding = 'binary' } return function(files, metalsmith, done){ selectedFiles = match(Object.keys(files), pattern) async.eachLimit(selectedFiles, 100, function(file, cb){ var data = files[file]; var dir = dirname(file); var html = basename(file, extname(file)) + extension; if ('.' != dir) html = dir + '/' + html; debug('Converting file %s', file); var md = data.contents.toString(); pandoc = pdc.stream(from, to, args, opts); var result = new Buffer(0); var chunks = []; var size = 0; var error = ''; // listen on error pandoc.on('error', function (err) { debug('error: ', err); return cb(err); }); // collect result data pandoc.stdout.on('data', function (data) { chunks.push(data); size += data.length; }); // collect error data pandoc.stderr.on('data', function (data) { error += data; }); // listen on exit pandoc.on('close', function (code) { var msg = ''; if (code !== 0) msg += 'pandoc exited with code ' + code + (error ? ': ' : '.'); if (error) msg += error; if (msg) return cb(new Error(msg)); var result = Buffer.concat(chunks, size); data.contents = result; delete files[file]; files[html] = data; cb(null, result); }); // finally, send source string pandoc.stdin.end(md, 'utf8'); }, done); }; }
javascript
function plugin(options){ options = options || {}; var from = options.from || 'markdown'; var to = options.to || 'html5'; var args = options.args || []; var opts = options.opts || {}; var pattern = options.pattern || '**/*.md'; var extension = options.ext || '.html'; if (to === 'docx' || to === 'pdf') { opts.encoding = 'binary' } return function(files, metalsmith, done){ selectedFiles = match(Object.keys(files), pattern) async.eachLimit(selectedFiles, 100, function(file, cb){ var data = files[file]; var dir = dirname(file); var html = basename(file, extname(file)) + extension; if ('.' != dir) html = dir + '/' + html; debug('Converting file %s', file); var md = data.contents.toString(); pandoc = pdc.stream(from, to, args, opts); var result = new Buffer(0); var chunks = []; var size = 0; var error = ''; // listen on error pandoc.on('error', function (err) { debug('error: ', err); return cb(err); }); // collect result data pandoc.stdout.on('data', function (data) { chunks.push(data); size += data.length; }); // collect error data pandoc.stderr.on('data', function (data) { error += data; }); // listen on exit pandoc.on('close', function (code) { var msg = ''; if (code !== 0) msg += 'pandoc exited with code ' + code + (error ? ': ' : '.'); if (error) msg += error; if (msg) return cb(new Error(msg)); var result = Buffer.concat(chunks, size); data.contents = result; delete files[file]; files[html] = data; cb(null, result); }); // finally, send source string pandoc.stdin.end(md, 'utf8'); }, done); }; }
[ "function", "plugin", "(", "options", ")", "{", "options", "=", "options", "||", "{", "}", ";", "var", "from", "=", "options", ".", "from", "||", "'markdown'", ";", "var", "to", "=", "options", ".", "to", "||", "'html5'", ";", "var", "args", "=", "options", ".", "args", "||", "[", "]", ";", "var", "opts", "=", "options", ".", "opts", "||", "{", "}", ";", "var", "pattern", "=", "options", ".", "pattern", "||", "'**/*.md'", ";", "var", "extension", "=", "options", ".", "ext", "||", "'.html'", ";", "if", "(", "to", "===", "'docx'", "||", "to", "===", "'pdf'", ")", "{", "opts", ".", "encoding", "=", "'binary'", "}", "return", "function", "(", "files", ",", "metalsmith", ",", "done", ")", "{", "selectedFiles", "=", "match", "(", "Object", ".", "keys", "(", "files", ")", ",", "pattern", ")", "async", ".", "eachLimit", "(", "selectedFiles", ",", "100", ",", "function", "(", "file", ",", "cb", ")", "{", "var", "data", "=", "files", "[", "file", "]", ";", "var", "dir", "=", "dirname", "(", "file", ")", ";", "var", "html", "=", "basename", "(", "file", ",", "extname", "(", "file", ")", ")", "+", "extension", ";", "if", "(", "'.'", "!=", "dir", ")", "html", "=", "dir", "+", "'/'", "+", "html", ";", "debug", "(", "'Converting file %s'", ",", "file", ")", ";", "var", "md", "=", "data", ".", "contents", ".", "toString", "(", ")", ";", "pandoc", "=", "pdc", ".", "stream", "(", "from", ",", "to", ",", "args", ",", "opts", ")", ";", "var", "result", "=", "new", "Buffer", "(", "0", ")", ";", "var", "chunks", "=", "[", "]", ";", "var", "size", "=", "0", ";", "var", "error", "=", "''", ";", "// listen on error", "pandoc", ".", "on", "(", "'error'", ",", "function", "(", "err", ")", "{", "debug", "(", "'error: '", ",", "err", ")", ";", "return", "cb", "(", "err", ")", ";", "}", ")", ";", "// collect result data", "pandoc", ".", "stdout", ".", "on", "(", "'data'", ",", "function", "(", "data", ")", "{", "chunks", ".", "push", "(", "data", ")", ";", "size", "+=", "data", ".", "length", ";", "}", ")", ";", "// collect error data", "pandoc", ".", "stderr", ".", "on", "(", "'data'", ",", "function", "(", "data", ")", "{", "error", "+=", "data", ";", "}", ")", ";", "// listen on exit", "pandoc", ".", "on", "(", "'close'", ",", "function", "(", "code", ")", "{", "var", "msg", "=", "''", ";", "if", "(", "code", "!==", "0", ")", "msg", "+=", "'pandoc exited with code '", "+", "code", "+", "(", "error", "?", "': '", ":", "'.'", ")", ";", "if", "(", "error", ")", "msg", "+=", "error", ";", "if", "(", "msg", ")", "return", "cb", "(", "new", "Error", "(", "msg", ")", ")", ";", "var", "result", "=", "Buffer", ".", "concat", "(", "chunks", ",", "size", ")", ";", "data", ".", "contents", "=", "result", ";", "delete", "files", "[", "file", "]", ";", "files", "[", "html", "]", "=", "data", ";", "cb", "(", "null", ",", "result", ")", ";", "}", ")", ";", "// finally, send source string", "pandoc", ".", "stdin", ".", "end", "(", "md", ",", "'utf8'", ")", ";", "}", ",", "done", ")", ";", "}", ";", "}" ]
Metalsmith plugin to convert files using pandoc.
[ "Metalsmith", "plugin", "to", "convert", "files", "using", "pandoc", "." ]
75d4c97850e0b3a32ce9b27a0984eb6cb901e42e
https://github.com/arve0/metalsmith-pandoc/blob/75d4c97850e0b3a32ce9b27a0984eb6cb901e42e/index.js#L32-L105
46,708
bmacheski/node-icloud
index.js
Device
function Device(apple_id, password, display_name) { if (!(this instanceof Device)) return new Device(apple_id, password, display_name); this.apple_id = apple_id; this.password = password; this.display_name = display_name; this.devices = []; this.authenticated = false; }
javascript
function Device(apple_id, password, display_name) { if (!(this instanceof Device)) return new Device(apple_id, password, display_name); this.apple_id = apple_id; this.password = password; this.display_name = display_name; this.devices = []; this.authenticated = false; }
[ "function", "Device", "(", "apple_id", ",", "password", ",", "display_name", ")", "{", "if", "(", "!", "(", "this", "instanceof", "Device", ")", ")", "return", "new", "Device", "(", "apple_id", ",", "password", ",", "display_name", ")", ";", "this", ".", "apple_id", "=", "apple_id", ";", "this", ".", "password", "=", "password", ";", "this", ".", "display_name", "=", "display_name", ";", "this", ".", "devices", "=", "[", "]", ";", "this", ".", "authenticated", "=", "false", ";", "}" ]
Initialize a new `Device`. @param {String} username @param {String} password @param {String} device_name
[ "Initialize", "a", "new", "Device", "." ]
ea4b7cf1e92f5603adb04872997a2e586491d7d7
https://github.com/bmacheski/node-icloud/blob/ea4b7cf1e92f5603adb04872997a2e586491d7d7/index.js#L33-L40
46,709
bmacheski/node-icloud
index.js
addDevices
function addDevices(deviceArr) { deviceArr.forEach(function(el, i) { self.devices.push({ name: deviceArr[i]['name'], deviceId: deviceArr[i]['id'] }); }); }
javascript
function addDevices(deviceArr) { deviceArr.forEach(function(el, i) { self.devices.push({ name: deviceArr[i]['name'], deviceId: deviceArr[i]['id'] }); }); }
[ "function", "addDevices", "(", "deviceArr", ")", "{", "deviceArr", ".", "forEach", "(", "function", "(", "el", ",", "i", ")", "{", "self", ".", "devices", ".", "push", "(", "{", "name", ":", "deviceArr", "[", "i", "]", "[", "'name'", "]", ",", "deviceId", ":", "deviceArr", "[", "i", "]", "[", "'id'", "]", "}", ")", ";", "}", ")", ";", "}" ]
Create array of available devices from response.
[ "Create", "array", "of", "available", "devices", "from", "response", "." ]
ea4b7cf1e92f5603adb04872997a2e586491d7d7
https://github.com/bmacheski/node-icloud/blob/ea4b7cf1e92f5603adb04872997a2e586491d7d7/index.js#L112-L119
46,710
bmacheski/node-icloud
index.js
function(res) { function addCookie(cookie) { try { cookieJar.setCookieSync(cookie, config.base_url); } catch (err) { throw err; } } if (Array.isArray(res.headers['set-cookie'])) { res.headers['set-cookie'].forEach(addCookie); } else { addCookie(res.headers['set-cookie']); } }
javascript
function(res) { function addCookie(cookie) { try { cookieJar.setCookieSync(cookie, config.base_url); } catch (err) { throw err; } } if (Array.isArray(res.headers['set-cookie'])) { res.headers['set-cookie'].forEach(addCookie); } else { addCookie(res.headers['set-cookie']); } }
[ "function", "(", "res", ")", "{", "function", "addCookie", "(", "cookie", ")", "{", "try", "{", "cookieJar", ".", "setCookieSync", "(", "cookie", ",", "config", ".", "base_url", ")", ";", "}", "catch", "(", "err", ")", "{", "throw", "err", ";", "}", "}", "if", "(", "Array", ".", "isArray", "(", "res", ".", "headers", "[", "'set-cookie'", "]", ")", ")", "{", "res", ".", "headers", "[", "'set-cookie'", "]", ".", "forEach", "(", "addCookie", ")", ";", "}", "else", "{", "addCookie", "(", "res", ".", "headers", "[", "'set-cookie'", "]", ")", ";", "}", "}" ]
Handle cookies required for iCloud services to function after authentication. @param {Object} res
[ "Handle", "cookies", "required", "for", "iCloud", "services", "to", "function", "after", "authentication", "." ]
ea4b7cf1e92f5603adb04872997a2e586491d7d7
https://github.com/bmacheski/node-icloud/blob/ea4b7cf1e92f5603adb04872997a2e586491d7d7/index.js#L180-L194
46,711
juanpicado/metalsmith-youtube
src/index.js
plugin
function plugin( _options ) { let options = _options || {}; return ( files, metalsmith, done ) => { let app = new Youtube( options, files ); app.parse( function() { done(); }); }; }
javascript
function plugin( _options ) { let options = _options || {}; return ( files, metalsmith, done ) => { let app = new Youtube( options, files ); app.parse( function() { done(); }); }; }
[ "function", "plugin", "(", "_options", ")", "{", "let", "options", "=", "_options", "||", "{", "}", ";", "return", "(", "files", ",", "metalsmith", ",", "done", ")", "=>", "{", "let", "app", "=", "new", "Youtube", "(", "options", ",", "files", ")", ";", "app", ".", "parse", "(", "function", "(", ")", "{", "done", "(", ")", ";", "}", ")", ";", "}", ";", "}" ]
Metalsmith plugin to render Youtube Video @param {Object} options (optional) @return {Function}
[ "Metalsmith", "plugin", "to", "render", "Youtube", "Video" ]
9e2cccc48a31ee85a3b0514aca8382368609bd3f
https://github.com/juanpicado/metalsmith-youtube/blob/9e2cccc48a31ee85a3b0514aca8382368609bd3f/src/index.js#L76-L84
46,712
alexindigo/deeply
merge.js
merge
function merge(to, from) { // if no suitable adapters found // just return overriding value var result = from , typeOf = getTypeOfAdapter.call(this) , type = typeOf(from) , adapter = getMergeByTypeAdapter.call(this, type) ; // if target object isn't the same type as the source object, // then override with new instance of the same type if (typeOf(to) != type) { to = getInitialValue(type, adapter); } // bind merge callback to the current context // so not to loose runtime flags result = adapter.call(this, to, from, merge.bind(this)); return result; }
javascript
function merge(to, from) { // if no suitable adapters found // just return overriding value var result = from , typeOf = getTypeOfAdapter.call(this) , type = typeOf(from) , adapter = getMergeByTypeAdapter.call(this, type) ; // if target object isn't the same type as the source object, // then override with new instance of the same type if (typeOf(to) != type) { to = getInitialValue(type, adapter); } // bind merge callback to the current context // so not to loose runtime flags result = adapter.call(this, to, from, merge.bind(this)); return result; }
[ "function", "merge", "(", "to", ",", "from", ")", "{", "// if no suitable adapters found", "// just return overriding value", "var", "result", "=", "from", ",", "typeOf", "=", "getTypeOfAdapter", ".", "call", "(", "this", ")", ",", "type", "=", "typeOf", "(", "from", ")", ",", "adapter", "=", "getMergeByTypeAdapter", ".", "call", "(", "this", ",", "type", ")", ";", "// if target object isn't the same type as the source object,", "// then override with new instance of the same type", "if", "(", "typeOf", "(", "to", ")", "!=", "type", ")", "{", "to", "=", "getInitialValue", "(", "type", ",", "adapter", ")", ";", "}", "// bind merge callback to the current context", "// so not to loose runtime flags", "result", "=", "adapter", ".", "call", "(", "this", ",", "to", ",", "from", ",", "merge", ".", "bind", "(", "this", ")", ")", ";", "return", "result", ";", "}" ]
Merges provided values, utilizing available adapters if no adapter found, reference to the same object will be returned, considering it as primitive value @param {mixed} to - value to merge into @param {mixed} from - value to merge @returns {mixed} - result of the merge
[ "Merges", "provided", "values", "utilizing", "available", "adapters", "if", "no", "adapter", "found", "reference", "to", "the", "same", "object", "will", "be", "returned", "considering", "it", "as", "primitive", "value" ]
d9f59eec37b75ce52038b3fcfb0fd86d4989c0c1
https://github.com/alexindigo/deeply/blob/d9f59eec37b75ce52038b3fcfb0fd86d4989c0c1/merge.js#L18-L40
46,713
alexindigo/deeply
merge.js
getMergeByTypeAdapter
function getMergeByTypeAdapter(type) { var adapter = adapters[type] || passThru; // only if usage of custom adapters is authorized // to prevent global context leaking in if (this.useCustomAdapters === behaviors.useCustomAdapters && typeof this[type] == 'function' ) { adapter = this[type]; } return adapter; }
javascript
function getMergeByTypeAdapter(type) { var adapter = adapters[type] || passThru; // only if usage of custom adapters is authorized // to prevent global context leaking in if (this.useCustomAdapters === behaviors.useCustomAdapters && typeof this[type] == 'function' ) { adapter = this[type]; } return adapter; }
[ "function", "getMergeByTypeAdapter", "(", "type", ")", "{", "var", "adapter", "=", "adapters", "[", "type", "]", "||", "passThru", ";", "// only if usage of custom adapters is authorized", "// to prevent global context leaking in", "if", "(", "this", ".", "useCustomAdapters", "===", "behaviors", ".", "useCustomAdapters", "&&", "typeof", "this", "[", "type", "]", "==", "'function'", ")", "{", "adapter", "=", "this", "[", "type", "]", ";", "}", "return", "adapter", ";", "}" ]
Returns merge adapter for the requested type either default one or custom one if provided @param {string} type - hook type to look for @returns {function} - merge adapter or pass-thru function, if not adapter found
[ "Returns", "merge", "adapter", "for", "the", "requested", "type", "either", "default", "one", "or", "custom", "one", "if", "provided" ]
d9f59eec37b75ce52038b3fcfb0fd86d4989c0c1
https://github.com/alexindigo/deeply/blob/d9f59eec37b75ce52038b3fcfb0fd86d4989c0c1/merge.js#L68-L82
46,714
alexindigo/deeply
merge.js
getInitialValue
function getInitialValue(type, adapter) { var value // should be either `window` or `global` , glob = typeof window == 'object' ? window : global // capitalize the first letter to make object constructor , objectType = type[0].toUpperCase() + type.substr(1) ; if (typeof adapter.initialValue == 'function') { value = adapter.initialValue(); } else if (objectType in glob) { // create new type object and get it's actual value // e.g. `new String().valueOf() // -> ''` value = new glob[objectType]().valueOf(); } // set initial value as `undefined` if no initialValue method found return value; }
javascript
function getInitialValue(type, adapter) { var value // should be either `window` or `global` , glob = typeof window == 'object' ? window : global // capitalize the first letter to make object constructor , objectType = type[0].toUpperCase() + type.substr(1) ; if (typeof adapter.initialValue == 'function') { value = adapter.initialValue(); } else if (objectType in glob) { // create new type object and get it's actual value // e.g. `new String().valueOf() // -> ''` value = new glob[objectType]().valueOf(); } // set initial value as `undefined` if no initialValue method found return value; }
[ "function", "getInitialValue", "(", "type", ",", "adapter", ")", "{", "var", "value", "// should be either `window` or `global`", ",", "glob", "=", "typeof", "window", "==", "'object'", "?", "window", ":", "global", "// capitalize the first letter to make object constructor", ",", "objectType", "=", "type", "[", "0", "]", ".", "toUpperCase", "(", ")", "+", "type", ".", "substr", "(", "1", ")", ";", "if", "(", "typeof", "adapter", ".", "initialValue", "==", "'function'", ")", "{", "value", "=", "adapter", ".", "initialValue", "(", ")", ";", "}", "else", "if", "(", "objectType", "in", "glob", ")", "{", "// create new type object and get it's actual value", "// e.g. `new String().valueOf() // -> ''`", "value", "=", "new", "glob", "[", "objectType", "]", "(", ")", ".", "valueOf", "(", ")", ";", "}", "// set initial value as `undefined` if no initialValue method found", "return", "value", ";", "}" ]
Creates initial value for the provided type @param {string} type - type to create new value of @param {function} adapter - adapter function with custom `initialValue` method @returns {mixed} - new value of the requested type
[ "Creates", "initial", "value", "for", "the", "provided", "type" ]
d9f59eec37b75ce52038b3fcfb0fd86d4989c0c1
https://github.com/alexindigo/deeply/blob/d9f59eec37b75ce52038b3fcfb0fd86d4989c0c1/merge.js#L91-L113
46,715
dpjanes/iotdb-homestar
bin/commands/old/add-id.js
function (filename) { if (!fs.existsSync(filename)) { logger.error({ method: "edit_add_cookbook_ids", filename: filename }, "file does not exist"); return; } var encoding = 'utf8'; var changed = false; var contents = fs.readFileSync(filename, encoding); var _replacer = function (full, cookbook_name) { changed = true; return util.format('homestar.cookbook(%s, "%s");', cookbook_name, uuid.v4()); }; contents = contents.replace(/^\s*homestar\s*.\s*cookbook\s*[(]\s*("[^"]*")\s*[)](\s*;)?/mg, _replacer); contents = contents.replace(/^\s*homestar\s*.\s*cookbook\s*[(]\s*('[^"]*')\s*[)](\s*;)?/mg, _replacer); if (changed) { fs.writeFileSync(filename, contents, { encoding: encoding }); logger.info({ method: "edit_add_cookbook_ids", filename: filename }, "updated recipe"); } }
javascript
function (filename) { if (!fs.existsSync(filename)) { logger.error({ method: "edit_add_cookbook_ids", filename: filename }, "file does not exist"); return; } var encoding = 'utf8'; var changed = false; var contents = fs.readFileSync(filename, encoding); var _replacer = function (full, cookbook_name) { changed = true; return util.format('homestar.cookbook(%s, "%s");', cookbook_name, uuid.v4()); }; contents = contents.replace(/^\s*homestar\s*.\s*cookbook\s*[(]\s*("[^"]*")\s*[)](\s*;)?/mg, _replacer); contents = contents.replace(/^\s*homestar\s*.\s*cookbook\s*[(]\s*('[^"]*')\s*[)](\s*;)?/mg, _replacer); if (changed) { fs.writeFileSync(filename, contents, { encoding: encoding }); logger.info({ method: "edit_add_cookbook_ids", filename: filename }, "updated recipe"); } }
[ "function", "(", "filename", ")", "{", "if", "(", "!", "fs", ".", "existsSync", "(", "filename", ")", ")", "{", "logger", ".", "error", "(", "{", "method", ":", "\"edit_add_cookbook_ids\"", ",", "filename", ":", "filename", "}", ",", "\"file does not exist\"", ")", ";", "return", ";", "}", "var", "encoding", "=", "'utf8'", ";", "var", "changed", "=", "false", ";", "var", "contents", "=", "fs", ".", "readFileSync", "(", "filename", ",", "encoding", ")", ";", "var", "_replacer", "=", "function", "(", "full", ",", "cookbook_name", ")", "{", "changed", "=", "true", ";", "return", "util", ".", "format", "(", "'homestar.cookbook(%s, \"%s\");'", ",", "cookbook_name", ",", "uuid", ".", "v4", "(", ")", ")", ";", "}", ";", "contents", "=", "contents", ".", "replace", "(", "/", "^\\s*homestar\\s*.\\s*cookbook\\s*[(]\\s*(\"[^\"]*\")\\s*[)](\\s*;)?", "/", "mg", ",", "_replacer", ")", ";", "contents", "=", "contents", ".", "replace", "(", "/", "^\\s*homestar\\s*.\\s*cookbook\\s*[(]\\s*('[^\"]*')\\s*[)](\\s*;)?", "/", "mg", ",", "_replacer", ")", ";", "if", "(", "changed", ")", "{", "fs", ".", "writeFileSync", "(", "filename", ",", "contents", ",", "{", "encoding", ":", "encoding", "}", ")", ";", "logger", ".", "info", "(", "{", "method", ":", "\"edit_add_cookbook_ids\"", ",", "filename", ":", "filename", "}", ",", "\"updated recipe\"", ")", ";", "}", "}" ]
This will edit a file and add UDIDs to Chapters <p> This is synchronous
[ "This", "will", "edit", "a", "file", "and", "add", "UDIDs", "to", "Chapters" ]
ed6535aa17c8b0538f43a876c9a6025e26a389e3
https://github.com/dpjanes/iotdb-homestar/blob/ed6535aa17c8b0538f43a876c9a6025e26a389e3/bin/commands/old/add-id.js#L41-L70
46,716
scijs/qr-solve
index.js
copy_row
function copy_row(nnz, offset, A, /*int* index, // const int* double* value, // const double* */ x) // x = sparseVector { for(var i=nnz-1; i>=0; --i) if(A.value[i + offset]){ x.push_front(new SparseEntry(A.column_index[i + offset], A.value[i + offset])); } return true; }
javascript
function copy_row(nnz, offset, A, /*int* index, // const int* double* value, // const double* */ x) // x = sparseVector { for(var i=nnz-1; i>=0; --i) if(A.value[i + offset]){ x.push_front(new SparseEntry(A.column_index[i + offset], A.value[i + offset])); } return true; }
[ "function", "copy_row", "(", "nnz", ",", "offset", ",", "A", ",", "/*int* index, // const int*\n double* value, // const double*\n */", "x", ")", "// x = sparseVector", "{", "for", "(", "var", "i", "=", "nnz", "-", "1", ";", "i", ">=", "0", ";", "--", "i", ")", "if", "(", "A", ".", "value", "[", "i", "+", "offset", "]", ")", "{", "x", ".", "push_front", "(", "new", "SparseEntry", "(", "A", ".", "column_index", "[", "i", "+", "offset", "]", ",", "A", ".", "value", "[", "i", "+", "offset", "]", ")", ")", ";", "}", "return", "true", ";", "}" ]
var proto = SparseVector.prototype
[ "var", "proto", "=", "SparseVector", ".", "prototype" ]
bf226a1ac836ec54e6f46f5324a30b692e85d2b6
https://github.com/scijs/qr-solve/blob/bf226a1ac836ec54e6f46f5324a30b692e85d2b6/index.js#L79-L92
46,717
SilentCicero/ethdeploy
src/loaders/solc-json/index.js
solcOutputLike
function solcOutputLike(obj) { let isSolcLike = false; Object.keys(obj).forEach((key) => { if (!isSolcLike && typeof obj[key] === 'object') { isSolcLike = (typeof obj[key].bytecode === 'string' && typeof obj[key].interface === 'string'); } }); return isSolcLike; }
javascript
function solcOutputLike(obj) { let isSolcLike = false; Object.keys(obj).forEach((key) => { if (!isSolcLike && typeof obj[key] === 'object') { isSolcLike = (typeof obj[key].bytecode === 'string' && typeof obj[key].interface === 'string'); } }); return isSolcLike; }
[ "function", "solcOutputLike", "(", "obj", ")", "{", "let", "isSolcLike", "=", "false", ";", "Object", ".", "keys", "(", "obj", ")", ".", "forEach", "(", "(", "key", ")", "=>", "{", "if", "(", "!", "isSolcLike", "&&", "typeof", "obj", "[", "key", "]", "===", "'object'", ")", "{", "isSolcLike", "=", "(", "typeof", "obj", "[", "key", "]", ".", "bytecode", "===", "'string'", "&&", "typeof", "obj", "[", "key", "]", ".", "interface", "===", "'string'", ")", ";", "}", "}", ")", ";", "return", "isSolcLike", ";", "}" ]
like solc output
[ "like", "solc", "output" ]
acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6
https://github.com/SilentCicero/ethdeploy/blob/acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6/src/loaders/solc-json/index.js#L2-L13
46,718
magora-labs/mgl-validate
lib/registry.js
Registry
function Registry(opt_options) { if (!(this instanceof Registry)) { return new Registry(opt_options); } opt_options = opt_options || {}; this.breakOnError = opt_options.breakOnError || false; this.depth = opt_options.depth || 10; // regex to match "$schema.*" this._match = /"\$id:[a-z0-9_-]*"/ig; // regex to escape strings for usage as regex this._escape = /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g; this.schemas = {}; }
javascript
function Registry(opt_options) { if (!(this instanceof Registry)) { return new Registry(opt_options); } opt_options = opt_options || {}; this.breakOnError = opt_options.breakOnError || false; this.depth = opt_options.depth || 10; // regex to match "$schema.*" this._match = /"\$id:[a-z0-9_-]*"/ig; // regex to escape strings for usage as regex this._escape = /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g; this.schemas = {}; }
[ "function", "Registry", "(", "opt_options", ")", "{", "if", "(", "!", "(", "this", "instanceof", "Registry", ")", ")", "{", "return", "new", "Registry", "(", "opt_options", ")", ";", "}", "opt_options", "=", "opt_options", "||", "{", "}", ";", "this", ".", "breakOnError", "=", "opt_options", ".", "breakOnError", "||", "false", ";", "this", ".", "depth", "=", "opt_options", ".", "depth", "||", "10", ";", "// regex to match \"$schema.*\"", "this", ".", "_match", "=", "/", "\"\\$id:[a-z0-9_-]*\"", "/", "ig", ";", "// regex to escape strings for usage as regex", "this", ".", "_escape", "=", "/", "[\\-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]", "/", "g", ";", "this", ".", "schemas", "=", "{", "}", ";", "}" ]
The schema registry @param {?Object=} opt_options The registry configuration @constructor
[ "The", "schema", "registry" ]
811b0d4f1e28ae3f21318f857ed63390aa74d89e
https://github.com/magora-labs/mgl-validate/blob/811b0d4f1e28ae3f21318f857ed63390aa74d89e/lib/registry.js#L12-L27
46,719
Justineo/kolor
kolor.js
function (items, i, j) { var k = items[i]; items[i] = items[j]; items[j] = k; }
javascript
function (items, i, j) { var k = items[i]; items[i] = items[j]; items[j] = k; }
[ "function", "(", "items", ",", "i", ",", "j", ")", "{", "var", "k", "=", "items", "[", "i", "]", ";", "items", "[", "i", "]", "=", "items", "[", "j", "]", ";", "items", "[", "j", "]", "=", "k", ";", "}" ]
Swaps two array elements.
[ "Swaps", "two", "array", "elements", "." ]
e02d41e32e85e1d5e414e1367c38a500d162e081
https://github.com/Justineo/kolor/blob/e02d41e32e85e1d5e414e1367c38a500d162e081/kolor.js#L56-L60
46,720
Justineo/kolor
kolor.js
function (source, callback, context) { var results = []; var i = source.length; while (i--) { results[i] = callback.call(context || source, source[i], i); } return results; }
javascript
function (source, callback, context) { var results = []; var i = source.length; while (i--) { results[i] = callback.call(context || source, source[i], i); } return results; }
[ "function", "(", "source", ",", "callback", ",", "context", ")", "{", "var", "results", "=", "[", "]", ";", "var", "i", "=", "source", ".", "length", ";", "while", "(", "i", "--", ")", "{", "results", "[", "i", "]", "=", "callback", ".", "call", "(", "context", "||", "source", ",", "source", "[", "i", "]", ",", "i", ")", ";", "}", "return", "results", ";", "}" ]
Iterates through the given array and produces a new array by mapping each value through a given function.
[ "Iterates", "through", "the", "given", "array", "and", "produces", "a", "new", "array", "by", "mapping", "each", "value", "through", "a", "given", "function", "." ]
e02d41e32e85e1d5e414e1367c38a500d162e081
https://github.com/Justineo/kolor/blob/e02d41e32e85e1d5e414e1367c38a500d162e081/kolor.js#L73-L80
46,721
Justineo/kolor
kolor.js
function (value, min, max) { var interval; if (min > max) { max = min + max; min = max - min; max = max - min; } interval = max - min; return min + ((value % interval) + interval) % interval; }
javascript
function (value, min, max) { var interval; if (min > max) { max = min + max; min = max - min; max = max - min; } interval = max - min; return min + ((value % interval) + interval) % interval; }
[ "function", "(", "value", ",", "min", ",", "max", ")", "{", "var", "interval", ";", "if", "(", "min", ">", "max", ")", "{", "max", "=", "min", "+", "max", ";", "min", "=", "max", "-", "min", ";", "max", "=", "max", "-", "min", ";", "}", "interval", "=", "max", "-", "min", ";", "return", "min", "+", "(", "(", "value", "%", "interval", ")", "+", "interval", ")", "%", "interval", ";", "}" ]
Wraps a number inside a given range with modulo operation.
[ "Wraps", "a", "number", "inside", "a", "given", "range", "with", "modulo", "operation", "." ]
e02d41e32e85e1d5e414e1367c38a500d162e081
https://github.com/Justineo/kolor/blob/e02d41e32e85e1d5e414e1367c38a500d162e081/kolor.js#L96-L105
46,722
Justineo/kolor
kolor.js
function (number, width) { number += ''; width -= number.length; if (width > 0) { return new Array(width + 1).join('0') + number; } return number + ''; }
javascript
function (number, width) { number += ''; width -= number.length; if (width > 0) { return new Array(width + 1).join('0') + number; } return number + ''; }
[ "function", "(", "number", ",", "width", ")", "{", "number", "+=", "''", ";", "width", "-=", "number", ".", "length", ";", "if", "(", "width", ">", "0", ")", "{", "return", "new", "Array", "(", "width", "+", "1", ")", ".", "join", "(", "'0'", ")", "+", "number", ";", "}", "return", "number", "+", "''", ";", "}" ]
Fills leading zeros for a number to make sure it has a fixed width.
[ "Fills", "leading", "zeros", "for", "a", "number", "to", "make", "sure", "it", "has", "a", "fixed", "width", "." ]
e02d41e32e85e1d5e414e1367c38a500d162e081
https://github.com/Justineo/kolor/blob/e02d41e32e85e1d5e414e1367c38a500d162e081/kolor.js#L108-L115
46,723
Justineo/kolor
kolor.js
fixHues
function fixHues(h1, h2) { var diff = Math.abs(NAMED_HUE_INDEX[h1] - NAMED_HUE_INDEX[h2]); if (diff !== 1 && diff !== 5) { return false; } var result = { h1: h1, h2: h2 }; if (h1 === 0 && h2 === 300) { result.h1 = 360; } else if (h2 === 0 && h1 === 300) { result.h2 = 360; } return result; }
javascript
function fixHues(h1, h2) { var diff = Math.abs(NAMED_HUE_INDEX[h1] - NAMED_HUE_INDEX[h2]); if (diff !== 1 && diff !== 5) { return false; } var result = { h1: h1, h2: h2 }; if (h1 === 0 && h2 === 300) { result.h1 = 360; } else if (h2 === 0 && h1 === 300) { result.h2 = 360; } return result; }
[ "function", "fixHues", "(", "h1", ",", "h2", ")", "{", "var", "diff", "=", "Math", ".", "abs", "(", "NAMED_HUE_INDEX", "[", "h1", "]", "-", "NAMED_HUE_INDEX", "[", "h2", "]", ")", ";", "if", "(", "diff", "!==", "1", "&&", "diff", "!==", "5", ")", "{", "return", "false", ";", "}", "var", "result", "=", "{", "h1", ":", "h1", ",", "h2", ":", "h2", "}", ";", "if", "(", "h1", "===", "0", "&&", "h2", "===", "300", ")", "{", "result", ".", "h1", "=", "360", ";", "}", "else", "if", "(", "h2", "===", "0", "&&", "h1", "===", "300", ")", "{", "result", ".", "h2", "=", "360", ";", "}", "return", "result", ";", "}" ]
0 -> 360 in some circumstances for correct calculation
[ "0", "-", ">", "360", "in", "some", "circumstances", "for", "correct", "calculation" ]
e02d41e32e85e1d5e414e1367c38a500d162e081
https://github.com/Justineo/kolor/blob/e02d41e32e85e1d5e414e1367c38a500d162e081/kolor.js#L328-L344
46,724
Justineo/kolor
kolor.js
parseNamedHues
function parseNamedHues(value) { var tokens = value.split(/\s+/); var l = tokens.length; if (l < 1 || l > 2) { return false; } var t1 = tokens[l - 1].toLowerCase(); if (!(t1 in BASE_HUE)) { return false; } var h1 = BASE_HUE[t1]; // single-value syntax if (l === 1) { return h1; } // double-value syntax var h2; var t2 = tokens[0].toLowerCase(); var hues; if (t2 in BASE_HUE) { h2 = BASE_HUE[t2]; hues = fixHues(h1, h2); return hues ? (hues.h1 + hues.h2) / 2 : false; } else if (t2 in SPLASH_HUE) { h2 = SPLASH_HUE[t2]; hues = fixHues(h1, h2); return hues ? (hues.h1 + (hues.h2 - hues.h1) / 4) : false; } else { var found = t2.match(/(\w+)\(\s*([^\)]+)\s*\)/i); if (!found) { return false; } t2 = found[1]; if (t2 in SPLASH_HUE) { h2 = SPLASH_HUE[t2]; hues = fixHues(h1, h2); var percent = DATATYPES[PERCENT].parse(found[2]); if (percent === false) { return percent; } return hues ? (hues.h1 + (hues.h2 - hues.h1) * percent) : false; } } return false; }
javascript
function parseNamedHues(value) { var tokens = value.split(/\s+/); var l = tokens.length; if (l < 1 || l > 2) { return false; } var t1 = tokens[l - 1].toLowerCase(); if (!(t1 in BASE_HUE)) { return false; } var h1 = BASE_HUE[t1]; // single-value syntax if (l === 1) { return h1; } // double-value syntax var h2; var t2 = tokens[0].toLowerCase(); var hues; if (t2 in BASE_HUE) { h2 = BASE_HUE[t2]; hues = fixHues(h1, h2); return hues ? (hues.h1 + hues.h2) / 2 : false; } else if (t2 in SPLASH_HUE) { h2 = SPLASH_HUE[t2]; hues = fixHues(h1, h2); return hues ? (hues.h1 + (hues.h2 - hues.h1) / 4) : false; } else { var found = t2.match(/(\w+)\(\s*([^\)]+)\s*\)/i); if (!found) { return false; } t2 = found[1]; if (t2 in SPLASH_HUE) { h2 = SPLASH_HUE[t2]; hues = fixHues(h1, h2); var percent = DATATYPES[PERCENT].parse(found[2]); if (percent === false) { return percent; } return hues ? (hues.h1 + (hues.h2 - hues.h1) * percent) : false; } } return false; }
[ "function", "parseNamedHues", "(", "value", ")", "{", "var", "tokens", "=", "value", ".", "split", "(", "/", "\\s+", "/", ")", ";", "var", "l", "=", "tokens", ".", "length", ";", "if", "(", "l", "<", "1", "||", "l", ">", "2", ")", "{", "return", "false", ";", "}", "var", "t1", "=", "tokens", "[", "l", "-", "1", "]", ".", "toLowerCase", "(", ")", ";", "if", "(", "!", "(", "t1", "in", "BASE_HUE", ")", ")", "{", "return", "false", ";", "}", "var", "h1", "=", "BASE_HUE", "[", "t1", "]", ";", "// single-value syntax\r", "if", "(", "l", "===", "1", ")", "{", "return", "h1", ";", "}", "// double-value syntax\r", "var", "h2", ";", "var", "t2", "=", "tokens", "[", "0", "]", ".", "toLowerCase", "(", ")", ";", "var", "hues", ";", "if", "(", "t2", "in", "BASE_HUE", ")", "{", "h2", "=", "BASE_HUE", "[", "t2", "]", ";", "hues", "=", "fixHues", "(", "h1", ",", "h2", ")", ";", "return", "hues", "?", "(", "hues", ".", "h1", "+", "hues", ".", "h2", ")", "/", "2", ":", "false", ";", "}", "else", "if", "(", "t2", "in", "SPLASH_HUE", ")", "{", "h2", "=", "SPLASH_HUE", "[", "t2", "]", ";", "hues", "=", "fixHues", "(", "h1", ",", "h2", ")", ";", "return", "hues", "?", "(", "hues", ".", "h1", "+", "(", "hues", ".", "h2", "-", "hues", ".", "h1", ")", "/", "4", ")", ":", "false", ";", "}", "else", "{", "var", "found", "=", "t2", ".", "match", "(", "/", "(\\w+)\\(\\s*([^\\)]+)\\s*\\)", "/", "i", ")", ";", "if", "(", "!", "found", ")", "{", "return", "false", ";", "}", "t2", "=", "found", "[", "1", "]", ";", "if", "(", "t2", "in", "SPLASH_HUE", ")", "{", "h2", "=", "SPLASH_HUE", "[", "t2", "]", ";", "hues", "=", "fixHues", "(", "h1", ",", "h2", ")", ";", "var", "percent", "=", "DATATYPES", "[", "PERCENT", "]", ".", "parse", "(", "found", "[", "2", "]", ")", ";", "if", "(", "percent", "===", "false", ")", "{", "return", "percent", ";", "}", "return", "hues", "?", "(", "hues", ".", "h1", "+", "(", "hues", ".", "h2", "-", "hues", ".", "h1", ")", "*", "percent", ")", ":", "false", ";", "}", "}", "return", "false", ";", "}" ]
Parses simple named hues
[ "Parses", "simple", "named", "hues" ]
e02d41e32e85e1d5e414e1367c38a500d162e081
https://github.com/Justineo/kolor/blob/e02d41e32e85e1d5e414e1367c38a500d162e081/kolor.js#L347-L398
46,725
Justineo/kolor
kolor.js
Octet
function Octet() { Channel.apply(this, arguments); this.dataType = INTEGER | PERCENT; this.cssType = INTEGER; this.range = [0, 255]; this.filter = CLAMP; this.initial = 255; }
javascript
function Octet() { Channel.apply(this, arguments); this.dataType = INTEGER | PERCENT; this.cssType = INTEGER; this.range = [0, 255]; this.filter = CLAMP; this.initial = 255; }
[ "function", "Octet", "(", ")", "{", "Channel", ".", "apply", "(", "this", ",", "arguments", ")", ";", "this", ".", "dataType", "=", "INTEGER", "|", "PERCENT", ";", "this", ".", "cssType", "=", "INTEGER", ";", "this", ".", "range", "=", "[", "0", ",", "255", "]", ";", "this", ".", "filter", "=", "CLAMP", ";", "this", ".", "initial", "=", "255", ";", "}" ]
Constructor for 0~255 integer or percentage.
[ "Constructor", "for", "0~255", "integer", "or", "percentage", "." ]
e02d41e32e85e1d5e414e1367c38a500d162e081
https://github.com/Justineo/kolor/blob/e02d41e32e85e1d5e414e1367c38a500d162e081/kolor.js#L552-L559
46,726
Justineo/kolor
kolor.js
Ratio
function Ratio() { Channel.apply(this, arguments); this.dataType = NUMBER | PERCENT; this.cssType = NUMBER; this.range = [0, 1]; this.filter = CLAMP; this.initial = 1; }
javascript
function Ratio() { Channel.apply(this, arguments); this.dataType = NUMBER | PERCENT; this.cssType = NUMBER; this.range = [0, 1]; this.filter = CLAMP; this.initial = 1; }
[ "function", "Ratio", "(", ")", "{", "Channel", ".", "apply", "(", "this", ",", "arguments", ")", ";", "this", ".", "dataType", "=", "NUMBER", "|", "PERCENT", ";", "this", ".", "cssType", "=", "NUMBER", ";", "this", ".", "range", "=", "[", "0", ",", "1", "]", ";", "this", ".", "filter", "=", "CLAMP", ";", "this", ".", "initial", "=", "1", ";", "}" ]
Constructor for channel can be number from 0~1 or percentage.
[ "Constructor", "for", "channel", "can", "be", "number", "from", "0~1", "or", "percentage", "." ]
e02d41e32e85e1d5e414e1367c38a500d162e081
https://github.com/Justineo/kolor/blob/e02d41e32e85e1d5e414e1367c38a500d162e081/kolor.js#L564-L571
46,727
Justineo/kolor
kolor.js
Hue
function Hue() { Channel.apply(this, arguments); this.dataType = NUMBER | HUE; this.cssType = NUMBER; this.range = [0, 360]; this.filter = MOD; this.initial = 0; }
javascript
function Hue() { Channel.apply(this, arguments); this.dataType = NUMBER | HUE; this.cssType = NUMBER; this.range = [0, 360]; this.filter = MOD; this.initial = 0; }
[ "function", "Hue", "(", ")", "{", "Channel", ".", "apply", "(", "this", ",", "arguments", ")", ";", "this", ".", "dataType", "=", "NUMBER", "|", "HUE", ";", "this", ".", "cssType", "=", "NUMBER", ";", "this", ".", "range", "=", "[", "0", ",", "360", "]", ";", "this", ".", "filter", "=", "MOD", ";", "this", ".", "initial", "=", "0", ";", "}" ]
Constructor for those channel can be .
[ "Constructor", "for", "those", "channel", "can", "be", "." ]
e02d41e32e85e1d5e414e1367c38a500d162e081
https://github.com/Justineo/kolor/blob/e02d41e32e85e1d5e414e1367c38a500d162e081/kolor.js#L584-L591
46,728
Justineo/kolor
kolor.js
ADD_ALPHA
function ADD_ALPHA() { var space = this.space(); var channels = SPACES[space].channels; var result = []; var l = channels.length; for (var i = 0; i < l; i++) { result.push(this[channels[i].name]()); } result.push(1); return new kolor[space + 'A'](result); }
javascript
function ADD_ALPHA() { var space = this.space(); var channels = SPACES[space].channels; var result = []; var l = channels.length; for (var i = 0; i < l; i++) { result.push(this[channels[i].name]()); } result.push(1); return new kolor[space + 'A'](result); }
[ "function", "ADD_ALPHA", "(", ")", "{", "var", "space", "=", "this", ".", "space", "(", ")", ";", "var", "channels", "=", "SPACES", "[", "space", "]", ".", "channels", ";", "var", "result", "=", "[", "]", ";", "var", "l", "=", "channels", ".", "length", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "l", ";", "i", "++", ")", "{", "result", ".", "push", "(", "this", "[", "channels", "[", "i", "]", ".", "name", "]", "(", ")", ")", ";", "}", "result", ".", "push", "(", "1", ")", ";", "return", "new", "kolor", "[", "space", "+", "'A'", "]", "(", "result", ")", ";", "}" ]
Produces a new color object by adding alpha channel to the old one.
[ "Produces", "a", "new", "color", "object", "by", "adding", "alpha", "channel", "to", "the", "old", "one", "." ]
e02d41e32e85e1d5e414e1367c38a500d162e081
https://github.com/Justineo/kolor/blob/e02d41e32e85e1d5e414e1367c38a500d162e081/kolor.js#L684-L695
46,729
Justineo/kolor
kolor.js
REMOVE_ALPHA
function REMOVE_ALPHA() { var space = this.space(); var channels = SPACES[space].channels; var result = []; var l = channels.length; for (var i = 0; i < l - 1; i++) { result.push(this[channels[i].name]()); } return new kolor[space.slice(0, -1)](result); }
javascript
function REMOVE_ALPHA() { var space = this.space(); var channels = SPACES[space].channels; var result = []; var l = channels.length; for (var i = 0; i < l - 1; i++) { result.push(this[channels[i].name]()); } return new kolor[space.slice(0, -1)](result); }
[ "function", "REMOVE_ALPHA", "(", ")", "{", "var", "space", "=", "this", ".", "space", "(", ")", ";", "var", "channels", "=", "SPACES", "[", "space", "]", ".", "channels", ";", "var", "result", "=", "[", "]", ";", "var", "l", "=", "channels", ".", "length", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "l", "-", "1", ";", "i", "++", ")", "{", "result", ".", "push", "(", "this", "[", "channels", "[", "i", "]", ".", "name", "]", "(", ")", ")", ";", "}", "return", "new", "kolor", "[", "space", ".", "slice", "(", "0", ",", "-", "1", ")", "]", "(", "result", ")", ";", "}" ]
Produces a new color object by removing alpha channel from the old one.
[ "Produces", "a", "new", "color", "object", "by", "removing", "alpha", "channel", "from", "the", "old", "one", "." ]
e02d41e32e85e1d5e414e1367c38a500d162e081
https://github.com/Justineo/kolor/blob/e02d41e32e85e1d5e414e1367c38a500d162e081/kolor.js#L698-L708
46,730
Justineo/kolor
kolor.js
RGBA_TO_CMYK
function RGBA_TO_CMYK() { var r = this.r() / 255; var g = this.g() / 255; var b = this.b() / 255; var black = 1 - Math.max(r, g, b); if (black === 0) { return kolor.cmyk(0, 0, 0, 0); } var c = (1 - r - black) / (1 - black); var m = (1 - g - black) / (1 - black); var y = (1 - b - black) / (1 - black); return kolor.cmyk(c, m, y, black, this.a()); }
javascript
function RGBA_TO_CMYK() { var r = this.r() / 255; var g = this.g() / 255; var b = this.b() / 255; var black = 1 - Math.max(r, g, b); if (black === 0) { return kolor.cmyk(0, 0, 0, 0); } var c = (1 - r - black) / (1 - black); var m = (1 - g - black) / (1 - black); var y = (1 - b - black) / (1 - black); return kolor.cmyk(c, m, y, black, this.a()); }
[ "function", "RGBA_TO_CMYK", "(", ")", "{", "var", "r", "=", "this", ".", "r", "(", ")", "/", "255", ";", "var", "g", "=", "this", ".", "g", "(", ")", "/", "255", ";", "var", "b", "=", "this", ".", "b", "(", ")", "/", "255", ";", "var", "black", "=", "1", "-", "Math", ".", "max", "(", "r", ",", "g", ",", "b", ")", ";", "if", "(", "black", "===", "0", ")", "{", "return", "kolor", ".", "cmyk", "(", "0", ",", "0", ",", "0", ",", "0", ")", ";", "}", "var", "c", "=", "(", "1", "-", "r", "-", "black", ")", "/", "(", "1", "-", "black", ")", ";", "var", "m", "=", "(", "1", "-", "g", "-", "black", ")", "/", "(", "1", "-", "black", ")", ";", "var", "y", "=", "(", "1", "-", "b", "-", "black", ")", "/", "(", "1", "-", "black", ")", ";", "return", "kolor", ".", "cmyk", "(", "c", ",", "m", ",", "y", ",", "black", ",", "this", ".", "a", "(", ")", ")", ";", "}" ]
Naively converts RGBA color to CMYK
[ "Naively", "converts", "RGBA", "color", "to", "CMYK" ]
e02d41e32e85e1d5e414e1367c38a500d162e081
https://github.com/Justineo/kolor/blob/e02d41e32e85e1d5e414e1367c38a500d162e081/kolor.js#L711-L725
46,731
Justineo/kolor
kolor.js
RGBA_TO_HSLA
function RGBA_TO_HSLA() { var r = this.r() / 255; var g = this.g() / 255; var b = this.b() / 255; var a = this.a(); var max = Math.max(r, g, b); var min = Math.min(r, g, b); var diff = max - min; var sum = max + min; var h; var s; var l; if (max === min) { h = 0; } else if (max === r && g >= b) { h = 60 * (g - b) / diff + 0; } else if (max === r && g < b) { h = 60 * (g - b) / diff + 360; } else if (max === g) { h = 60 * (b - r) / diff + 120; } else { // max === b h = 60 * (r - g) / diff + 240; } l = sum / 2; if (l === 0 || max === min) { s = 0; } else if (0 < l && l <= 0.5) { s = diff / sum; } else { // l > 0.5 s = diff / (2 - sum); } return kolor.hsla(h, s, l, a); }
javascript
function RGBA_TO_HSLA() { var r = this.r() / 255; var g = this.g() / 255; var b = this.b() / 255; var a = this.a(); var max = Math.max(r, g, b); var min = Math.min(r, g, b); var diff = max - min; var sum = max + min; var h; var s; var l; if (max === min) { h = 0; } else if (max === r && g >= b) { h = 60 * (g - b) / diff + 0; } else if (max === r && g < b) { h = 60 * (g - b) / diff + 360; } else if (max === g) { h = 60 * (b - r) / diff + 120; } else { // max === b h = 60 * (r - g) / diff + 240; } l = sum / 2; if (l === 0 || max === min) { s = 0; } else if (0 < l && l <= 0.5) { s = diff / sum; } else { // l > 0.5 s = diff / (2 - sum); } return kolor.hsla(h, s, l, a); }
[ "function", "RGBA_TO_HSLA", "(", ")", "{", "var", "r", "=", "this", ".", "r", "(", ")", "/", "255", ";", "var", "g", "=", "this", ".", "g", "(", ")", "/", "255", ";", "var", "b", "=", "this", ".", "b", "(", ")", "/", "255", ";", "var", "a", "=", "this", ".", "a", "(", ")", ";", "var", "max", "=", "Math", ".", "max", "(", "r", ",", "g", ",", "b", ")", ";", "var", "min", "=", "Math", ".", "min", "(", "r", ",", "g", ",", "b", ")", ";", "var", "diff", "=", "max", "-", "min", ";", "var", "sum", "=", "max", "+", "min", ";", "var", "h", ";", "var", "s", ";", "var", "l", ";", "if", "(", "max", "===", "min", ")", "{", "h", "=", "0", ";", "}", "else", "if", "(", "max", "===", "r", "&&", "g", ">=", "b", ")", "{", "h", "=", "60", "*", "(", "g", "-", "b", ")", "/", "diff", "+", "0", ";", "}", "else", "if", "(", "max", "===", "r", "&&", "g", "<", "b", ")", "{", "h", "=", "60", "*", "(", "g", "-", "b", ")", "/", "diff", "+", "360", ";", "}", "else", "if", "(", "max", "===", "g", ")", "{", "h", "=", "60", "*", "(", "b", "-", "r", ")", "/", "diff", "+", "120", ";", "}", "else", "{", "// max === b\r", "h", "=", "60", "*", "(", "r", "-", "g", ")", "/", "diff", "+", "240", ";", "}", "l", "=", "sum", "/", "2", ";", "if", "(", "l", "===", "0", "||", "max", "===", "min", ")", "{", "s", "=", "0", ";", "}", "else", "if", "(", "0", "<", "l", "&&", "l", "<=", "0.5", ")", "{", "s", "=", "diff", "/", "sum", ";", "}", "else", "{", "// l > 0.5\r", "s", "=", "diff", "/", "(", "2", "-", "sum", ")", ";", "}", "return", "kolor", ".", "hsla", "(", "h", ",", "s", ",", "l", ",", "a", ")", ";", "}" ]
Converts RGBA color to HSLA.
[ "Converts", "RGBA", "color", "to", "HSLA", "." ]
e02d41e32e85e1d5e414e1367c38a500d162e081
https://github.com/Justineo/kolor/blob/e02d41e32e85e1d5e414e1367c38a500d162e081/kolor.js#L728-L764
46,732
Justineo/kolor
kolor.js
RGBA_TO_HSVA
function RGBA_TO_HSVA() { var r = this.r() / 255; var g = this.g() / 255; var b = this.b() / 255; var a = this.a(); var max = Math.max(r, g, b); var min = Math.min(r, g, b); var diff = max - min; var h; var s; if (max === min) { h = 0; } else if (max === r && g >= b) { h = 60 * (g - b) / diff + 0; } else if (max === r && g < b) { h = 60 * (g - b) / diff + 360; } else if (max === g) { h = 60 * (b - r) / diff + 120; } else { // max === b h = 60 * (r - g) / diff + 240; } if (max === 0) { s = 0; } else { s = diff / max; } var v = max; return kolor.hsva(h, s, v, a); }
javascript
function RGBA_TO_HSVA() { var r = this.r() / 255; var g = this.g() / 255; var b = this.b() / 255; var a = this.a(); var max = Math.max(r, g, b); var min = Math.min(r, g, b); var diff = max - min; var h; var s; if (max === min) { h = 0; } else if (max === r && g >= b) { h = 60 * (g - b) / diff + 0; } else if (max === r && g < b) { h = 60 * (g - b) / diff + 360; } else if (max === g) { h = 60 * (b - r) / diff + 120; } else { // max === b h = 60 * (r - g) / diff + 240; } if (max === 0) { s = 0; } else { s = diff / max; } var v = max; return kolor.hsva(h, s, v, a); }
[ "function", "RGBA_TO_HSVA", "(", ")", "{", "var", "r", "=", "this", ".", "r", "(", ")", "/", "255", ";", "var", "g", "=", "this", ".", "g", "(", ")", "/", "255", ";", "var", "b", "=", "this", ".", "b", "(", ")", "/", "255", ";", "var", "a", "=", "this", ".", "a", "(", ")", ";", "var", "max", "=", "Math", ".", "max", "(", "r", ",", "g", ",", "b", ")", ";", "var", "min", "=", "Math", ".", "min", "(", "r", ",", "g", ",", "b", ")", ";", "var", "diff", "=", "max", "-", "min", ";", "var", "h", ";", "var", "s", ";", "if", "(", "max", "===", "min", ")", "{", "h", "=", "0", ";", "}", "else", "if", "(", "max", "===", "r", "&&", "g", ">=", "b", ")", "{", "h", "=", "60", "*", "(", "g", "-", "b", ")", "/", "diff", "+", "0", ";", "}", "else", "if", "(", "max", "===", "r", "&&", "g", "<", "b", ")", "{", "h", "=", "60", "*", "(", "g", "-", "b", ")", "/", "diff", "+", "360", ";", "}", "else", "if", "(", "max", "===", "g", ")", "{", "h", "=", "60", "*", "(", "b", "-", "r", ")", "/", "diff", "+", "120", ";", "}", "else", "{", "// max === b\r", "h", "=", "60", "*", "(", "r", "-", "g", ")", "/", "diff", "+", "240", ";", "}", "if", "(", "max", "===", "0", ")", "{", "s", "=", "0", ";", "}", "else", "{", "s", "=", "diff", "/", "max", ";", "}", "var", "v", "=", "max", ";", "return", "kolor", ".", "hsva", "(", "h", ",", "s", ",", "v", ",", "a", ")", ";", "}" ]
Converts RGBA color to HSVA.
[ "Converts", "RGBA", "color", "to", "HSVA", "." ]
e02d41e32e85e1d5e414e1367c38a500d162e081
https://github.com/Justineo/kolor/blob/e02d41e32e85e1d5e414e1367c38a500d162e081/kolor.js#L767-L798
46,733
Justineo/kolor
kolor.js
HSLA_TO_RGBA
function HSLA_TO_RGBA() { var h = this.h(); var s = this.s(); var l = this.l(); var a = this.a(); var q = l < 0.5 ? l * (1 + s) : l + s - l * s; var p = 2 * l - q; var hk = h / 360; var t = {}; var rgb = {}; t.r = hk + 1 / 3; t.g = hk; t.b = hk - 1 / 3; var c; for (c in t) { t[c] < 0 && t[c] ++; t[c] > 1 && t[c] --; } for (c in t) { if (t[c] < 1 / 6) { rgb[c] = p + ((q - p) * 6 * t[c]); } else if (1 / 6 <= t[c] && t[c] < 0.5) { rgb[c] = q; } else if (0.5 <= t[c] && t[c] < 2 / 3) { rgb[c] = p + ((q - p) * 6 * (2 / 3 - t[c])); } else { // t[c] >= 2 / 3 rgb[c] = p; } rgb[c] *= 255; } return kolor.rgba(rgb.r, rgb.g, rgb.b, a); }
javascript
function HSLA_TO_RGBA() { var h = this.h(); var s = this.s(); var l = this.l(); var a = this.a(); var q = l < 0.5 ? l * (1 + s) : l + s - l * s; var p = 2 * l - q; var hk = h / 360; var t = {}; var rgb = {}; t.r = hk + 1 / 3; t.g = hk; t.b = hk - 1 / 3; var c; for (c in t) { t[c] < 0 && t[c] ++; t[c] > 1 && t[c] --; } for (c in t) { if (t[c] < 1 / 6) { rgb[c] = p + ((q - p) * 6 * t[c]); } else if (1 / 6 <= t[c] && t[c] < 0.5) { rgb[c] = q; } else if (0.5 <= t[c] && t[c] < 2 / 3) { rgb[c] = p + ((q - p) * 6 * (2 / 3 - t[c])); } else { // t[c] >= 2 / 3 rgb[c] = p; } rgb[c] *= 255; } return kolor.rgba(rgb.r, rgb.g, rgb.b, a); }
[ "function", "HSLA_TO_RGBA", "(", ")", "{", "var", "h", "=", "this", ".", "h", "(", ")", ";", "var", "s", "=", "this", ".", "s", "(", ")", ";", "var", "l", "=", "this", ".", "l", "(", ")", ";", "var", "a", "=", "this", ".", "a", "(", ")", ";", "var", "q", "=", "l", "<", "0.5", "?", "l", "*", "(", "1", "+", "s", ")", ":", "l", "+", "s", "-", "l", "*", "s", ";", "var", "p", "=", "2", "*", "l", "-", "q", ";", "var", "hk", "=", "h", "/", "360", ";", "var", "t", "=", "{", "}", ";", "var", "rgb", "=", "{", "}", ";", "t", ".", "r", "=", "hk", "+", "1", "/", "3", ";", "t", ".", "g", "=", "hk", ";", "t", ".", "b", "=", "hk", "-", "1", "/", "3", ";", "var", "c", ";", "for", "(", "c", "in", "t", ")", "{", "t", "[", "c", "]", "<", "0", "&&", "t", "[", "c", "]", "++", ";", "t", "[", "c", "]", ">", "1", "&&", "t", "[", "c", "]", "--", ";", "}", "for", "(", "c", "in", "t", ")", "{", "if", "(", "t", "[", "c", "]", "<", "1", "/", "6", ")", "{", "rgb", "[", "c", "]", "=", "p", "+", "(", "(", "q", "-", "p", ")", "*", "6", "*", "t", "[", "c", "]", ")", ";", "}", "else", "if", "(", "1", "/", "6", "<=", "t", "[", "c", "]", "&&", "t", "[", "c", "]", "<", "0.5", ")", "{", "rgb", "[", "c", "]", "=", "q", ";", "}", "else", "if", "(", "0.5", "<=", "t", "[", "c", "]", "&&", "t", "[", "c", "]", "<", "2", "/", "3", ")", "{", "rgb", "[", "c", "]", "=", "p", "+", "(", "(", "q", "-", "p", ")", "*", "6", "*", "(", "2", "/", "3", "-", "t", "[", "c", "]", ")", ")", ";", "}", "else", "{", "// t[c] >= 2 / 3\r", "rgb", "[", "c", "]", "=", "p", ";", "}", "rgb", "[", "c", "]", "*=", "255", ";", "}", "return", "kolor", ".", "rgba", "(", "rgb", ".", "r", ",", "rgb", ".", "g", ",", "rgb", ".", "b", ",", "a", ")", ";", "}" ]
Converts HSLA color to RGBA.
[ "Converts", "HSLA", "color", "to", "RGBA", "." ]
e02d41e32e85e1d5e414e1367c38a500d162e081
https://github.com/Justineo/kolor/blob/e02d41e32e85e1d5e414e1367c38a500d162e081/kolor.js#L806-L842
46,734
Justineo/kolor
kolor.js
HSLA_TO_HSVA
function HSLA_TO_HSVA() { var h = this.h(); var s = this.s(); var l = this.l(); var a = this.a(); l *= 2; s *= (l <= 1) ? l : 2 - l; var v = (l + s) / 2; var sv = (2 * s) / (l + s); return kolor.hsva(h, sv, v, a); }
javascript
function HSLA_TO_HSVA() { var h = this.h(); var s = this.s(); var l = this.l(); var a = this.a(); l *= 2; s *= (l <= 1) ? l : 2 - l; var v = (l + s) / 2; var sv = (2 * s) / (l + s); return kolor.hsva(h, sv, v, a); }
[ "function", "HSLA_TO_HSVA", "(", ")", "{", "var", "h", "=", "this", ".", "h", "(", ")", ";", "var", "s", "=", "this", ".", "s", "(", ")", ";", "var", "l", "=", "this", ".", "l", "(", ")", ";", "var", "a", "=", "this", ".", "a", "(", ")", ";", "l", "*=", "2", ";", "s", "*=", "(", "l", "<=", "1", ")", "?", "l", ":", "2", "-", "l", ";", "var", "v", "=", "(", "l", "+", "s", ")", "/", "2", ";", "var", "sv", "=", "(", "2", "*", "s", ")", "/", "(", "l", "+", "s", ")", ";", "return", "kolor", ".", "hsva", "(", "h", ",", "sv", ",", "v", ",", "a", ")", ";", "}" ]
Converts HSLA color to HSVA.
[ "Converts", "HSLA", "color", "to", "HSVA", "." ]
e02d41e32e85e1d5e414e1367c38a500d162e081
https://github.com/Justineo/kolor/blob/e02d41e32e85e1d5e414e1367c38a500d162e081/kolor.js#L845-L856
46,735
Justineo/kolor
kolor.js
HSVA_TO_RGBA
function HSVA_TO_RGBA() { var h = this.h(); var s = this.s(); var v = this.v(); var a = this.a(); var hi = Math.floor(h / 60); var f = h / 60 - hi; var p = v * (1 - s); var q = v * (1 - f * s); var t = v * (1 - (1 - f) * s); var rgba; switch (hi) { case 0: rgba = [v, t, p, a]; break; case 1: rgba = [q, v, p, a]; break; case 2: rgba = [p, v, t, a]; break; case 3: rgba = [p, q, v, a]; break; case 4: rgba = [t, p, v, a]; break; case 5: rgba = [v, p, q, a]; break; default: rgba = [0, 0, 0, a]; } for (var i = rgba.length - 1; i--;) { rgba[i] *= 255; } return kolor.rgba(rgba); }
javascript
function HSVA_TO_RGBA() { var h = this.h(); var s = this.s(); var v = this.v(); var a = this.a(); var hi = Math.floor(h / 60); var f = h / 60 - hi; var p = v * (1 - s); var q = v * (1 - f * s); var t = v * (1 - (1 - f) * s); var rgba; switch (hi) { case 0: rgba = [v, t, p, a]; break; case 1: rgba = [q, v, p, a]; break; case 2: rgba = [p, v, t, a]; break; case 3: rgba = [p, q, v, a]; break; case 4: rgba = [t, p, v, a]; break; case 5: rgba = [v, p, q, a]; break; default: rgba = [0, 0, 0, a]; } for (var i = rgba.length - 1; i--;) { rgba[i] *= 255; } return kolor.rgba(rgba); }
[ "function", "HSVA_TO_RGBA", "(", ")", "{", "var", "h", "=", "this", ".", "h", "(", ")", ";", "var", "s", "=", "this", ".", "s", "(", ")", ";", "var", "v", "=", "this", ".", "v", "(", ")", ";", "var", "a", "=", "this", ".", "a", "(", ")", ";", "var", "hi", "=", "Math", ".", "floor", "(", "h", "/", "60", ")", ";", "var", "f", "=", "h", "/", "60", "-", "hi", ";", "var", "p", "=", "v", "*", "(", "1", "-", "s", ")", ";", "var", "q", "=", "v", "*", "(", "1", "-", "f", "*", "s", ")", ";", "var", "t", "=", "v", "*", "(", "1", "-", "(", "1", "-", "f", ")", "*", "s", ")", ";", "var", "rgba", ";", "switch", "(", "hi", ")", "{", "case", "0", ":", "rgba", "=", "[", "v", ",", "t", ",", "p", ",", "a", "]", ";", "break", ";", "case", "1", ":", "rgba", "=", "[", "q", ",", "v", ",", "p", ",", "a", "]", ";", "break", ";", "case", "2", ":", "rgba", "=", "[", "p", ",", "v", ",", "t", ",", "a", "]", ";", "break", ";", "case", "3", ":", "rgba", "=", "[", "p", ",", "q", ",", "v", ",", "a", "]", ";", "break", ";", "case", "4", ":", "rgba", "=", "[", "t", ",", "p", ",", "v", ",", "a", "]", ";", "break", ";", "case", "5", ":", "rgba", "=", "[", "v", ",", "p", ",", "q", ",", "a", "]", ";", "break", ";", "default", ":", "rgba", "=", "[", "0", ",", "0", ",", "0", ",", "a", "]", ";", "}", "for", "(", "var", "i", "=", "rgba", ".", "length", "-", "1", ";", "i", "--", ";", ")", "{", "rgba", "[", "i", "]", "*=", "255", ";", "}", "return", "kolor", ".", "rgba", "(", "rgba", ")", ";", "}" ]
Converts HSVA color to RGBA.
[ "Converts", "HSVA", "color", "to", "RGBA", "." ]
e02d41e32e85e1d5e414e1367c38a500d162e081
https://github.com/Justineo/kolor/blob/e02d41e32e85e1d5e414e1367c38a500d162e081/kolor.js#L859-L893
46,736
Justineo/kolor
kolor.js
HSVA_TO_HSLA
function HSVA_TO_HSLA() { var h = this.h(); var s = this.s(); var v = this.v(); var a = this.a(); var l = (2 - s) * v; var sl = s * v; sl /= (l <= 1) ? l : 2 - l; sl = sl || 0; l /= 2; return kolor.hsla(h, sl, l, a); }
javascript
function HSVA_TO_HSLA() { var h = this.h(); var s = this.s(); var v = this.v(); var a = this.a(); var l = (2 - s) * v; var sl = s * v; sl /= (l <= 1) ? l : 2 - l; sl = sl || 0; l /= 2; return kolor.hsla(h, sl, l, a); }
[ "function", "HSVA_TO_HSLA", "(", ")", "{", "var", "h", "=", "this", ".", "h", "(", ")", ";", "var", "s", "=", "this", ".", "s", "(", ")", ";", "var", "v", "=", "this", ".", "v", "(", ")", ";", "var", "a", "=", "this", ".", "a", "(", ")", ";", "var", "l", "=", "(", "2", "-", "s", ")", "*", "v", ";", "var", "sl", "=", "s", "*", "v", ";", "sl", "/=", "(", "l", "<=", "1", ")", "?", "l", ":", "2", "-", "l", ";", "sl", "=", "sl", "||", "0", ";", "l", "/=", "2", ";", "return", "kolor", ".", "hsla", "(", "h", ",", "sl", ",", "l", ",", "a", ")", ";", "}" ]
Converts HSVA color to HSLA.
[ "Converts", "HSVA", "color", "to", "HSLA", "." ]
e02d41e32e85e1d5e414e1367c38a500d162e081
https://github.com/Justineo/kolor/blob/e02d41e32e85e1d5e414e1367c38a500d162e081/kolor.js#L896-L908
46,737
Justineo/kolor
kolor.js
HSVA_TO_HWB
function HSVA_TO_HWB() { var h = this.h(); var s = this.s(); var v = this.v(); var a = this.a(); return kolor.hwb(h, (1 - s) * v, 1 - v, a); }
javascript
function HSVA_TO_HWB() { var h = this.h(); var s = this.s(); var v = this.v(); var a = this.a(); return kolor.hwb(h, (1 - s) * v, 1 - v, a); }
[ "function", "HSVA_TO_HWB", "(", ")", "{", "var", "h", "=", "this", ".", "h", "(", ")", ";", "var", "s", "=", "this", ".", "s", "(", ")", ";", "var", "v", "=", "this", ".", "v", "(", ")", ";", "var", "a", "=", "this", ".", "a", "(", ")", ";", "return", "kolor", ".", "hwb", "(", "h", ",", "(", "1", "-", "s", ")", "*", "v", ",", "1", "-", "v", ",", "a", ")", ";", "}" ]
Converts HSVA color to HWB.
[ "Converts", "HSVA", "color", "to", "HWB", "." ]
e02d41e32e85e1d5e414e1367c38a500d162e081
https://github.com/Justineo/kolor/blob/e02d41e32e85e1d5e414e1367c38a500d162e081/kolor.js#L911-L917
46,738
Justineo/kolor
kolor.js
HWB_TO_HSVA
function HWB_TO_HSVA() { var h = this.h(); var w = this.w(); var b = this.b(); var a = this.a(); return kolor.hsva(h, 1 - w / (1 - b), 1 - b, a); }
javascript
function HWB_TO_HSVA() { var h = this.h(); var w = this.w(); var b = this.b(); var a = this.a(); return kolor.hsva(h, 1 - w / (1 - b), 1 - b, a); }
[ "function", "HWB_TO_HSVA", "(", ")", "{", "var", "h", "=", "this", ".", "h", "(", ")", ";", "var", "w", "=", "this", ".", "w", "(", ")", ";", "var", "b", "=", "this", ".", "b", "(", ")", ";", "var", "a", "=", "this", ".", "a", "(", ")", ";", "return", "kolor", ".", "hsva", "(", "h", ",", "1", "-", "w", "/", "(", "1", "-", "b", ")", ",", "1", "-", "b", ",", "a", ")", ";", "}" ]
Converts HWB color to HSVA.
[ "Converts", "HWB", "color", "to", "HSVA", "." ]
e02d41e32e85e1d5e414e1367c38a500d162e081
https://github.com/Justineo/kolor/blob/e02d41e32e85e1d5e414e1367c38a500d162e081/kolor.js#L920-L926
46,739
Justineo/kolor
kolor.js
GRAY_TO_RGBA
function GRAY_TO_RGBA() { var s = this.s(); var a = this.a(); return kolor.rgba(s, s, s, a); }
javascript
function GRAY_TO_RGBA() { var s = this.s(); var a = this.a(); return kolor.rgba(s, s, s, a); }
[ "function", "GRAY_TO_RGBA", "(", ")", "{", "var", "s", "=", "this", ".", "s", "(", ")", ";", "var", "a", "=", "this", ".", "a", "(", ")", ";", "return", "kolor", ".", "rgba", "(", "s", ",", "s", ",", "s", ",", "a", ")", ";", "}" ]
Converts GRAY color to RGBA.
[ "Converts", "GRAY", "color", "to", "RGBA", "." ]
e02d41e32e85e1d5e414e1367c38a500d162e081
https://github.com/Justineo/kolor/blob/e02d41e32e85e1d5e414e1367c38a500d162e081/kolor.js#L929-L934
46,740
Justineo/kolor
kolor.js
CMYK_TO_RGBA
function CMYK_TO_RGBA() { var c = this.c(); var m = this.m(); var y = this.y(); var black = this.b(); var r = 1 - Math.min(1, c * (1 - black) + black); var g = 1 - Math.min(1, m * (1 - black) + black); var b = 1 - Math.min(1, y * (1 - black) + black); return kolor.rgba(r * 255, g * 255, b * 255, this.a()); }
javascript
function CMYK_TO_RGBA() { var c = this.c(); var m = this.m(); var y = this.y(); var black = this.b(); var r = 1 - Math.min(1, c * (1 - black) + black); var g = 1 - Math.min(1, m * (1 - black) + black); var b = 1 - Math.min(1, y * (1 - black) + black); return kolor.rgba(r * 255, g * 255, b * 255, this.a()); }
[ "function", "CMYK_TO_RGBA", "(", ")", "{", "var", "c", "=", "this", ".", "c", "(", ")", ";", "var", "m", "=", "this", ".", "m", "(", ")", ";", "var", "y", "=", "this", ".", "y", "(", ")", ";", "var", "black", "=", "this", ".", "b", "(", ")", ";", "var", "r", "=", "1", "-", "Math", ".", "min", "(", "1", ",", "c", "*", "(", "1", "-", "black", ")", "+", "black", ")", ";", "var", "g", "=", "1", "-", "Math", ".", "min", "(", "1", ",", "m", "*", "(", "1", "-", "black", ")", "+", "black", ")", ";", "var", "b", "=", "1", "-", "Math", ".", "min", "(", "1", ",", "y", "*", "(", "1", "-", "black", ")", "+", "black", ")", ";", "return", "kolor", ".", "rgba", "(", "r", "*", "255", ",", "g", "*", "255", ",", "b", "*", "255", ",", "this", ".", "a", "(", ")", ")", ";", "}" ]
Naively converts CMYK color to RGBA.
[ "Naively", "converts", "CMYK", "color", "to", "RGBA", "." ]
e02d41e32e85e1d5e414e1367c38a500d162e081
https://github.com/Justineo/kolor/blob/e02d41e32e85e1d5e414e1367c38a500d162e081/kolor.js#L937-L947
46,741
Justineo/kolor
kolor.js
getConverters
function getConverters(from, to) { if (from === to) { return []; } if (CONVERTERS[from][to]) { return [to]; } var queue = [from]; var path = {}; path[from] = []; while (queue.length) { var v = queue.shift(); for (var w in CONVERTERS[v]) { if (!path[w]) { queue.push(w); path[w] = path[v].concat([w]); if (w === to) { return path[w]; } } } } return null; }
javascript
function getConverters(from, to) { if (from === to) { return []; } if (CONVERTERS[from][to]) { return [to]; } var queue = [from]; var path = {}; path[from] = []; while (queue.length) { var v = queue.shift(); for (var w in CONVERTERS[v]) { if (!path[w]) { queue.push(w); path[w] = path[v].concat([w]); if (w === to) { return path[w]; } } } } return null; }
[ "function", "getConverters", "(", "from", ",", "to", ")", "{", "if", "(", "from", "===", "to", ")", "{", "return", "[", "]", ";", "}", "if", "(", "CONVERTERS", "[", "from", "]", "[", "to", "]", ")", "{", "return", "[", "to", "]", ";", "}", "var", "queue", "=", "[", "from", "]", ";", "var", "path", "=", "{", "}", ";", "path", "[", "from", "]", "=", "[", "]", ";", "while", "(", "queue", ".", "length", ")", "{", "var", "v", "=", "queue", ".", "shift", "(", ")", ";", "for", "(", "var", "w", "in", "CONVERTERS", "[", "v", "]", ")", "{", "if", "(", "!", "path", "[", "w", "]", ")", "{", "queue", ".", "push", "(", "w", ")", ";", "path", "[", "w", "]", "=", "path", "[", "v", "]", ".", "concat", "(", "[", "w", "]", ")", ";", "if", "(", "w", "===", "to", ")", "{", "return", "path", "[", "w", "]", ";", "}", "}", "}", "}", "return", "null", ";", "}" ]
Breadth-first search to find the conversion path
[ "Breadth", "-", "first", "search", "to", "find", "the", "conversion", "path" ]
e02d41e32e85e1d5e414e1367c38a500d162e081
https://github.com/Justineo/kolor/blob/e02d41e32e85e1d5e414e1367c38a500d162e081/kolor.js#L989-L1016
46,742
Justineo/kolor
kolor.js
filterValue
function filterValue(value, channel) { var type; for (var key in DATATYPES) { type = DATATYPES[key]; if (type.flag & channel.dataType) { var val = type.parse(value); if (val !== false) { if (type.flag === PERCENT) { val *= Math.abs(channel.range[1] - channel.range[0]); } return channel.filter(val); } } } return channel.initial; }
javascript
function filterValue(value, channel) { var type; for (var key in DATATYPES) { type = DATATYPES[key]; if (type.flag & channel.dataType) { var val = type.parse(value); if (val !== false) { if (type.flag === PERCENT) { val *= Math.abs(channel.range[1] - channel.range[0]); } return channel.filter(val); } } } return channel.initial; }
[ "function", "filterValue", "(", "value", ",", "channel", ")", "{", "var", "type", ";", "for", "(", "var", "key", "in", "DATATYPES", ")", "{", "type", "=", "DATATYPES", "[", "key", "]", ";", "if", "(", "type", ".", "flag", "&", "channel", ".", "dataType", ")", "{", "var", "val", "=", "type", ".", "parse", "(", "value", ")", ";", "if", "(", "val", "!==", "false", ")", "{", "if", "(", "type", ".", "flag", "===", "PERCENT", ")", "{", "val", "*=", "Math", ".", "abs", "(", "channel", ".", "range", "[", "1", "]", "-", "channel", ".", "range", "[", "0", "]", ")", ";", "}", "return", "channel", ".", "filter", "(", "val", ")", ";", "}", "}", "}", "return", "channel", ".", "initial", ";", "}" ]
Filters input value according to data type definitions and color space configurations.
[ "Filters", "input", "value", "according", "to", "data", "type", "definitions", "and", "color", "space", "configurations", "." ]
e02d41e32e85e1d5e414e1367c38a500d162e081
https://github.com/Justineo/kolor/blob/e02d41e32e85e1d5e414e1367c38a500d162e081/kolor.js#L1020-L1035
46,743
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(event_name, fn, context, listener_args) { return this._addListener(event_name, fn, context, listener_args, this._listeners) }
javascript
function(event_name, fn, context, listener_args) { return this._addListener(event_name, fn, context, listener_args, this._listeners) }
[ "function", "(", "event_name", ",", "fn", ",", "context", ",", "listener_args", ")", "{", "return", "this", ".", "_addListener", "(", "event_name", ",", "fn", ",", "context", ",", "listener_args", ",", "this", ".", "_listeners", ")", "}" ]
Add listener for event `event_name` @param {string} event_name Name of the event to listen to @param {function} fn The callback @param {Object} context The context for callback execution (an object, to which the callback belongs) @param {*} [listener_args] Static listener arguments. May be usable when one callback responds to different events @returns {_tListener} Listener structure, which later may be suspended, or removed via call to {@link Lava.mixin.Observable#removeListener}
[ "Add", "listener", "for", "event", "event_name" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L31-L35
46,744
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(event_name, fn, context, listener_args, listeners_by_event) { // otherwise, listener would be called on window object if (Lava.schema.DEBUG && !context) Lava.t('Listener was created without a context'); // note 1: member count for a plain object like this must not exceed 8 // otherwise, chrome will slow down greatly (!) // note 2: there is no 'remove()' method inside the listener, cause depending on implementation, // it may either slow down script execution or lead to memory leaks var listener = { event_name: event_name, fn: fn, fn_original: fn, context: context, listener_args: listener_args }; if (listeners_by_event[event_name] != null) { listeners_by_event[event_name].push(listener); } else { listeners_by_event[event_name] = [listener]; } return listener; }
javascript
function(event_name, fn, context, listener_args, listeners_by_event) { // otherwise, listener would be called on window object if (Lava.schema.DEBUG && !context) Lava.t('Listener was created without a context'); // note 1: member count for a plain object like this must not exceed 8 // otherwise, chrome will slow down greatly (!) // note 2: there is no 'remove()' method inside the listener, cause depending on implementation, // it may either slow down script execution or lead to memory leaks var listener = { event_name: event_name, fn: fn, fn_original: fn, context: context, listener_args: listener_args }; if (listeners_by_event[event_name] != null) { listeners_by_event[event_name].push(listener); } else { listeners_by_event[event_name] = [listener]; } return listener; }
[ "function", "(", "event_name", ",", "fn", ",", "context", ",", "listener_args", ",", "listeners_by_event", ")", "{", "// otherwise, listener would be called on window object", "if", "(", "Lava", ".", "schema", ".", "DEBUG", "&&", "!", "context", ")", "Lava", ".", "t", "(", "'Listener was created without a context'", ")", ";", "// note 1: member count for a plain object like this must not exceed 8", "// otherwise, chrome will slow down greatly (!)", "// note 2: there is no 'remove()' method inside the listener, cause depending on implementation,", "// it may either slow down script execution or lead to memory leaks", "var", "listener", "=", "{", "event_name", ":", "event_name", ",", "fn", ":", "fn", ",", "fn_original", ":", "fn", ",", "context", ":", "context", ",", "listener_args", ":", "listener_args", "}", ";", "if", "(", "listeners_by_event", "[", "event_name", "]", "!=", "null", ")", "{", "listeners_by_event", "[", "event_name", "]", ".", "push", "(", "listener", ")", ";", "}", "else", "{", "listeners_by_event", "[", "event_name", "]", "=", "[", "listener", "]", ";", "}", "return", "listener", ";", "}" ]
Create the listener construct and push it into the listeners array for given event name @param {string} event_name The name of event @param {function} fn The callback @param {Object} context The owner of the callback @param {*} listener_args Static listener arguments @param {Object.<string, Array.<_tListener>>} listeners_by_event {@link Lava.mixin.Observable#_listeners} or {@link Lava.mixin.Properties#_property_listeners} @returns {_tListener} Listener structure
[ "Create", "the", "listener", "construct", "and", "push", "it", "into", "the", "listeners", "array", "for", "given", "event", "name" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L47-L76
46,745
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(listener, listeners_by_event) { var list = listeners_by_event[listener.event_name], index; if (list) { index = list.indexOf(listener); if (index != -1) { list.splice(index, 1); if (list.length == 0) { listeners_by_event[listener.event_name] = null; } } } }
javascript
function(listener, listeners_by_event) { var list = listeners_by_event[listener.event_name], index; if (list) { index = list.indexOf(listener); if (index != -1) { list.splice(index, 1); if (list.length == 0) { listeners_by_event[listener.event_name] = null; } } } }
[ "function", "(", "listener", ",", "listeners_by_event", ")", "{", "var", "list", "=", "listeners_by_event", "[", "listener", ".", "event_name", "]", ",", "index", ";", "if", "(", "list", ")", "{", "index", "=", "list", ".", "indexOf", "(", "listener", ")", ";", "if", "(", "index", "!=", "-", "1", ")", "{", "list", ".", "splice", "(", "index", ",", "1", ")", ";", "if", "(", "list", ".", "length", "==", "0", ")", "{", "listeners_by_event", "[", "listener", ".", "event_name", "]", "=", "null", ";", "}", "}", "}", "}" ]
Perform removal of the listener structure @param {_tListener} listener Structure, which was returned by {@link Lava.mixin.Observable#on} method @param {Object.<string, Array.<_tListener>>} listeners_by_event {@link Lava.mixin.Observable#_listeners} or {@link Lava.mixin.Properties#_property_listeners}
[ "Perform", "removal", "of", "the", "listener", "structure" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L93-L108
46,746
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(listeners, event_args) { var copy = listeners.slice(), // cause they may be removed during the fire cycle i = 0, count = listeners.length, listener; for (; i < count; i++) { listener = copy[i]; listener.fn.call(listener.context, this, event_args, listener.listener_args); } }
javascript
function(listeners, event_args) { var copy = listeners.slice(), // cause they may be removed during the fire cycle i = 0, count = listeners.length, listener; for (; i < count; i++) { listener = copy[i]; listener.fn.call(listener.context, this, event_args, listener.listener_args); } }
[ "function", "(", "listeners", ",", "event_args", ")", "{", "var", "copy", "=", "listeners", ".", "slice", "(", ")", ",", "// cause they may be removed during the fire cycle", "i", "=", "0", ",", "count", "=", "listeners", ".", "length", ",", "listener", ";", "for", "(", ";", "i", "<", "count", ";", "i", "++", ")", "{", "listener", "=", "copy", "[", "i", "]", ";", "listener", ".", "fn", ".", "call", "(", "listener", ".", "context", ",", "this", ",", "event_args", ",", "listener", ".", "listener_args", ")", ";", "}", "}" ]
Perform fire - call listeners of an event @param {Array.<_tListener>} listeners An array with listener structures @param {*} event_args Dynamic event arguments
[ "Perform", "fire", "-", "call", "listeners", "of", "an", "event" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L132-L146
46,747
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(properties_object) { if (Lava.schema.DEBUG && properties_object && properties_object.isProperties) Lava.t("setProperties expects a plain JS object as an argument, not a class"); for (var name in properties_object) { this.set(name, properties_object[name]); } }
javascript
function(properties_object) { if (Lava.schema.DEBUG && properties_object && properties_object.isProperties) Lava.t("setProperties expects a plain JS object as an argument, not a class"); for (var name in properties_object) { this.set(name, properties_object[name]); } }
[ "function", "(", "properties_object", ")", "{", "if", "(", "Lava", ".", "schema", ".", "DEBUG", "&&", "properties_object", "&&", "properties_object", ".", "isProperties", ")", "Lava", ".", "t", "(", "\"setProperties expects a plain JS object as an argument, not a class\"", ")", ";", "for", "(", "var", "name", "in", "properties_object", ")", "{", "this", ".", "set", "(", "name", ",", "properties_object", "[", "name", "]", ")", ";", "}", "}" ]
Set multiple properties at once @param {Object.<string, *>} properties_object A hash with new property values
[ "Set", "multiple", "properties", "at", "once" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L259-L269
46,748
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(config, target) { this.guid = Lava.guid++; if (config.duration) { this._duration = config.duration; } this._target = target; this._transition = config.transition || Lava.transitions[config.transition_name || 'linear']; this._config = config; }
javascript
function(config, target) { this.guid = Lava.guid++; if (config.duration) { this._duration = config.duration; } this._target = target; this._transition = config.transition || Lava.transitions[config.transition_name || 'linear']; this._config = config; }
[ "function", "(", "config", ",", "target", ")", "{", "this", ".", "guid", "=", "Lava", ".", "guid", "++", ";", "if", "(", "config", ".", "duration", ")", "{", "this", ".", "_duration", "=", "config", ".", "duration", ";", "}", "this", ".", "_target", "=", "target", ";", "this", ".", "_transition", "=", "config", ".", "transition", "||", "Lava", ".", "transitions", "[", "config", ".", "transition_name", "||", "'linear'", "]", ";", "this", ".", "_config", "=", "config", ";", "}" ]
Constructs the class instance @param {_cAnimation} config Settings, `this._config` @param {*} target `this._target`
[ "Constructs", "the", "class", "instance" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L665-L675
46,749
kogarashisan/LiquidLava
lib/packages/core-classes.js
function() { this._is_reversed = !this._is_reversed; if (this._is_running) { var now = new Date().getTime(), new_end = 2 * now - this._started_time; // it's possible in case of script lags. Must not allow negative transition values. if (now > this._end_time) { this._started_time = this._end_time; this._end_time = this._started_time + this._duration; } else { this._end_time = new_end; this._started_time = new_end - this._duration; } this._afterMirror(now); } }
javascript
function() { this._is_reversed = !this._is_reversed; if (this._is_running) { var now = new Date().getTime(), new_end = 2 * now - this._started_time; // it's possible in case of script lags. Must not allow negative transition values. if (now > this._end_time) { this._started_time = this._end_time; this._end_time = this._started_time + this._duration; } else { this._end_time = new_end; this._started_time = new_end - this._duration; } this._afterMirror(now); } }
[ "function", "(", ")", "{", "this", ".", "_is_reversed", "=", "!", "this", ".", "_is_reversed", ";", "if", "(", "this", ".", "_is_running", ")", "{", "var", "now", "=", "new", "Date", "(", ")", ".", "getTime", "(", ")", ",", "new_end", "=", "2", "*", "now", "-", "this", ".", "_started_time", ";", "// it's possible in case of script lags. Must not allow negative transition values.", "if", "(", "now", ">", "this", ".", "_end_time", ")", "{", "this", ".", "_started_time", "=", "this", ".", "_end_time", ";", "this", ".", "_end_time", "=", "this", ".", "_started_time", "+", "this", ".", "_duration", ";", "}", "else", "{", "this", ".", "_end_time", "=", "new_end", ";", "this", ".", "_started_time", "=", "new_end", "-", "this", ".", "_duration", ";", "}", "this", ".", "_afterMirror", "(", "now", ")", ";", "}", "}" ]
Reverse animation direction
[ "Reverse", "animation", "direction" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L741-L767
46,750
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(transition_value) { for (var i = 0, count = this._animators.length; i < count; i++) { this._animators[i].animate(this._target, transition_value); } }
javascript
function(transition_value) { for (var i = 0, count = this._animators.length; i < count; i++) { this._animators[i].animate(this._target, transition_value); } }
[ "function", "(", "transition_value", ")", "{", "for", "(", "var", "i", "=", "0", ",", "count", "=", "this", ".", "_animators", ".", "length", ";", "i", "<", "count", ";", "i", "++", ")", "{", "this", ".", "_animators", "[", "i", "]", ".", "animate", "(", "this", ".", "_target", ",", "transition_value", ")", ";", "}", "}" ]
Calls all animator instances. This function may be substituted with pre-generated version from `_shared` @param {number} transition_value The current percent of animation
[ "Calls", "all", "animator", "instances", ".", "This", "function", "may", "be", "substituted", "with", "pre", "-", "generated", "version", "from", "_shared" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L939-L947
46,751
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(now) { if (now < this._end_time) { this._callAnimators(this._transition((now - this._started_time) / this._duration)); } else { this._callAnimators(this._transition(1)); this._finish(); } }
javascript
function(now) { if (now < this._end_time) { this._callAnimators(this._transition((now - this._started_time) / this._duration)); } else { this._callAnimators(this._transition(1)); this._finish(); } }
[ "function", "(", "now", ")", "{", "if", "(", "now", "<", "this", ".", "_end_time", ")", "{", "this", ".", "_callAnimators", "(", "this", ".", "_transition", "(", "(", "now", "-", "this", ".", "_started_time", ")", "/", "this", ".", "_duration", ")", ")", ";", "}", "else", "{", "this", ".", "_callAnimators", "(", "this", ".", "_transition", "(", "1", ")", ")", ";", "this", ".", "_finish", "(", ")", ";", "}", "}" ]
Perform animation in normal direction @param {number} now The current global time in milliseconds
[ "Perform", "animation", "in", "normal", "direction" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L953-L966
46,752
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(config) { if (config) { if (config.check_property_names === false) this._check_property_names = false; } this._serializeFunction = (config && config.pretty_print_functions) ? this._serializeFunction_PrettyPrint : this._serializeFunction_Normal }
javascript
function(config) { if (config) { if (config.check_property_names === false) this._check_property_names = false; } this._serializeFunction = (config && config.pretty_print_functions) ? this._serializeFunction_PrettyPrint : this._serializeFunction_Normal }
[ "function", "(", "config", ")", "{", "if", "(", "config", ")", "{", "if", "(", "config", ".", "check_property_names", "===", "false", ")", "this", ".", "_check_property_names", "=", "false", ";", "}", "this", ".", "_serializeFunction", "=", "(", "config", "&&", "config", ".", "pretty_print_functions", ")", "?", "this", ".", "_serializeFunction_PrettyPrint", ":", "this", ".", "_serializeFunction_Normal", "}" ]
Create Serializer instance @param {?_cSerializer} config
[ "Create", "Serializer", "instance" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L1446-L1456
46,753
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(value, padding) { var type = Firestorm.getType(value), result; if (Lava.schema.DEBUG && !(type in this._callback_map)) Lava.t("Unsupported type for serialization: " + type); result = this[this._callback_map[type]](value, padding); return result; }
javascript
function(value, padding) { var type = Firestorm.getType(value), result; if (Lava.schema.DEBUG && !(type in this._callback_map)) Lava.t("Unsupported type for serialization: " + type); result = this[this._callback_map[type]](value, padding); return result; }
[ "function", "(", "value", ",", "padding", ")", "{", "var", "type", "=", "Firestorm", ".", "getType", "(", "value", ")", ",", "result", ";", "if", "(", "Lava", ".", "schema", ".", "DEBUG", "&&", "!", "(", "type", "in", "this", ".", "_callback_map", ")", ")", "Lava", ".", "t", "(", "\"Unsupported type for serialization: \"", "+", "type", ")", ";", "result", "=", "this", "[", "this", ".", "_callback_map", "[", "type", "]", "]", "(", "value", ",", "padding", ")", ";", "return", "result", ";", "}" ]
Perform value serialization @param {*} value @param {string} padding The initial padding for JavaScript code @returns {string}
[ "Perform", "value", "serialization" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L1475-L1486
46,754
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(data, padding) { var tempResult = [], i = 0, count = data.length, child_padding = padding + "\t", result; if (count == 0) { result = '[]'; } else if (count == 1) { result = '[' + this._serializeValue(data[i], padding) + ']'; } else { for (; i < count; i++) { tempResult.push(this._serializeValue(data[i], child_padding)); } result = '[' + "\n\t" + padding + tempResult.join(",\n\t" + padding) + "\n" + padding + ']'; } return result; }
javascript
function(data, padding) { var tempResult = [], i = 0, count = data.length, child_padding = padding + "\t", result; if (count == 0) { result = '[]'; } else if (count == 1) { result = '[' + this._serializeValue(data[i], padding) + ']'; } else { for (; i < count; i++) { tempResult.push(this._serializeValue(data[i], child_padding)); } result = '[' + "\n\t" + padding + tempResult.join(",\n\t" + padding) + "\n" + padding + ']'; } return result; }
[ "function", "(", "data", ",", "padding", ")", "{", "var", "tempResult", "=", "[", "]", ",", "i", "=", "0", ",", "count", "=", "data", ".", "length", ",", "child_padding", "=", "padding", "+", "\"\\t\"", ",", "result", ";", "if", "(", "count", "==", "0", ")", "{", "result", "=", "'[]'", ";", "}", "else", "if", "(", "count", "==", "1", ")", "{", "result", "=", "'['", "+", "this", ".", "_serializeValue", "(", "data", "[", "i", "]", ",", "padding", ")", "+", "']'", ";", "}", "else", "{", "for", "(", ";", "i", "<", "count", ";", "i", "++", ")", "{", "tempResult", ".", "push", "(", "this", ".", "_serializeValue", "(", "data", "[", "i", "]", ",", "child_padding", ")", ")", ";", "}", "result", "=", "'['", "+", "\"\\n\\t\"", "+", "padding", "+", "tempResult", ".", "join", "(", "\",\\n\\t\"", "+", "padding", ")", "+", "\"\\n\"", "+", "padding", "+", "']'", ";", "}", "return", "result", ";", "}" ]
Perform serialization of an array @param {Array} data @param {string} padding @returns {string}
[ "Perform", "serialization", "of", "an", "array" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L1494-L1524
46,755
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(data, padding) { var tempResult = [], child_padding = padding + "\t", name, type, result, is_complex = false, only_key = null, is_empty = true; // this may be faster than using Object.keys(data), but I haven't done speed comparison yet. // Purpose of the following code: // 1) if object has something in it then 'is_empty' will be set to false // 2) if there is only one property in it, then 'only_key' will contain it's name for (name in data) { if (only_key !== null) { // strict comparison - in case the key is valid, but evaluates to false only_key = null; break; } is_empty = false; only_key = name; } if (only_key) { type = Firestorm.getType(data[only_key]); if (type in this._complex_types) { is_complex = true; } } if (is_empty) { result = '{}'; } else if (only_key && !is_complex) { // simple values can be written in one line result = '{' + this._serializeObjectProperty(only_key, data[only_key], child_padding) + '}'; } else { for (name in data) { tempResult.push( this._serializeObjectProperty(name, data[name], child_padding) ); } result = '{' + "\n\t" + padding + tempResult.join(",\n\t" + padding) + "\n" + padding + '}'; } return result; }
javascript
function(data, padding) { var tempResult = [], child_padding = padding + "\t", name, type, result, is_complex = false, only_key = null, is_empty = true; // this may be faster than using Object.keys(data), but I haven't done speed comparison yet. // Purpose of the following code: // 1) if object has something in it then 'is_empty' will be set to false // 2) if there is only one property in it, then 'only_key' will contain it's name for (name in data) { if (only_key !== null) { // strict comparison - in case the key is valid, but evaluates to false only_key = null; break; } is_empty = false; only_key = name; } if (only_key) { type = Firestorm.getType(data[only_key]); if (type in this._complex_types) { is_complex = true; } } if (is_empty) { result = '{}'; } else if (only_key && !is_complex) { // simple values can be written in one line result = '{' + this._serializeObjectProperty(only_key, data[only_key], child_padding) + '}'; } else { for (name in data) { tempResult.push( this._serializeObjectProperty(name, data[name], child_padding) ); } result = '{' + "\n\t" + padding + tempResult.join(",\n\t" + padding) + "\n" + padding + '}'; } return result; }
[ "function", "(", "data", ",", "padding", ")", "{", "var", "tempResult", "=", "[", "]", ",", "child_padding", "=", "padding", "+", "\"\\t\"", ",", "name", ",", "type", ",", "result", ",", "is_complex", "=", "false", ",", "only_key", "=", "null", ",", "is_empty", "=", "true", ";", "// this may be faster than using Object.keys(data), but I haven't done speed comparison yet.", "// Purpose of the following code:", "// 1) if object has something in it then 'is_empty' will be set to false", "// 2) if there is only one property in it, then 'only_key' will contain it's name", "for", "(", "name", "in", "data", ")", "{", "if", "(", "only_key", "!==", "null", ")", "{", "// strict comparison - in case the key is valid, but evaluates to false", "only_key", "=", "null", ";", "break", ";", "}", "is_empty", "=", "false", ";", "only_key", "=", "name", ";", "}", "if", "(", "only_key", ")", "{", "type", "=", "Firestorm", ".", "getType", "(", "data", "[", "only_key", "]", ")", ";", "if", "(", "type", "in", "this", ".", "_complex_types", ")", "{", "is_complex", "=", "true", ";", "}", "}", "if", "(", "is_empty", ")", "{", "result", "=", "'{}'", ";", "}", "else", "if", "(", "only_key", "&&", "!", "is_complex", ")", "{", "// simple values can be written in one line", "result", "=", "'{'", "+", "this", ".", "_serializeObjectProperty", "(", "only_key", ",", "data", "[", "only_key", "]", ",", "child_padding", ")", "+", "'}'", ";", "}", "else", "{", "for", "(", "name", "in", "data", ")", "{", "tempResult", ".", "push", "(", "this", ".", "_serializeObjectProperty", "(", "name", ",", "data", "[", "name", "]", ",", "child_padding", ")", ")", ";", "}", "result", "=", "'{'", "+", "\"\\n\\t\"", "+", "padding", "+", "tempResult", ".", "join", "(", "\",\\n\\t\"", "+", "padding", ")", "+", "\"\\n\"", "+", "padding", "+", "'}'", ";", "}", "return", "result", ";", "}" ]
Serialize an object @param {Object} data @param {string} padding @returns {string}
[ "Serialize", "an", "object" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L1543-L1602
46,756
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(name, value, padding) { var type = Firestorm.getType(value); // if you serialize only Lava configs, then most likely you do not need this check, // cause the property names in configs are always valid. if (this._check_property_names && (!Lava.VALID_PROPERTY_NAME_REGEX.test(name) || Lava.JS_KEYWORDS.indexOf(name) != -1)) { name = Firestorm.String.quote(name); } return name + ': ' + this[this._callback_map[type]](value, padding); }
javascript
function(name, value, padding) { var type = Firestorm.getType(value); // if you serialize only Lava configs, then most likely you do not need this check, // cause the property names in configs are always valid. if (this._check_property_names && (!Lava.VALID_PROPERTY_NAME_REGEX.test(name) || Lava.JS_KEYWORDS.indexOf(name) != -1)) { name = Firestorm.String.quote(name); } return name + ': ' + this[this._callback_map[type]](value, padding); }
[ "function", "(", "name", ",", "value", ",", "padding", ")", "{", "var", "type", "=", "Firestorm", ".", "getType", "(", "value", ")", ";", "// if you serialize only Lava configs, then most likely you do not need this check,", "// cause the property names in configs are always valid.", "if", "(", "this", ".", "_check_property_names", "&&", "(", "!", "Lava", ".", "VALID_PROPERTY_NAME_REGEX", ".", "test", "(", "name", ")", "||", "Lava", ".", "JS_KEYWORDS", ".", "indexOf", "(", "name", ")", "!=", "-", "1", ")", ")", "{", "name", "=", "Firestorm", ".", "String", ".", "quote", "(", "name", ")", ";", "}", "return", "name", "+", "': '", "+", "this", "[", "this", ".", "_callback_map", "[", "type", "]", "]", "(", "value", ",", "padding", ")", ";", "}" ]
Serialize one key-value pair in an object @param {string} name @param {*} value @param {string} padding @returns {string}
[ "Serialize", "one", "key", "-", "value", "pair", "in", "an", "object" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L1611-L1625
46,757
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(data, padding) { var result = this._serializeFunction_Normal(data), lines = result.split(/\r?\n/), last_line = lines[lines.length - 1], tabs, num_tabs, i = 1, count = lines.length; if (/^\t*\}$/.test(last_line)) { if (last_line.length > 1) { // if there are tabs tabs = last_line.substr(0, last_line.length - 1); num_tabs = tabs.length; for (; i < count; i++) { if (lines[i].indexOf(tabs) == 0) { lines[i] = lines[i].substr(num_tabs); } } } lines.pop(); result = lines.join('\r\n\t' + padding) + '\r\n' + padding + last_line; } return result; }
javascript
function(data, padding) { var result = this._serializeFunction_Normal(data), lines = result.split(/\r?\n/), last_line = lines[lines.length - 1], tabs, num_tabs, i = 1, count = lines.length; if (/^\t*\}$/.test(last_line)) { if (last_line.length > 1) { // if there are tabs tabs = last_line.substr(0, last_line.length - 1); num_tabs = tabs.length; for (; i < count; i++) { if (lines[i].indexOf(tabs) == 0) { lines[i] = lines[i].substr(num_tabs); } } } lines.pop(); result = lines.join('\r\n\t' + padding) + '\r\n' + padding + last_line; } return result; }
[ "function", "(", "data", ",", "padding", ")", "{", "var", "result", "=", "this", ".", "_serializeFunction_Normal", "(", "data", ")", ",", "lines", "=", "result", ".", "split", "(", "/", "\\r?\\n", "/", ")", ",", "last_line", "=", "lines", "[", "lines", ".", "length", "-", "1", "]", ",", "tabs", ",", "num_tabs", ",", "i", "=", "1", ",", "count", "=", "lines", ".", "length", ";", "if", "(", "/", "^\\t*\\}$", "/", ".", "test", "(", "last_line", ")", ")", "{", "if", "(", "last_line", ".", "length", ">", "1", ")", "{", "// if there are tabs", "tabs", "=", "last_line", ".", "substr", "(", "0", ",", "last_line", ".", "length", "-", "1", ")", ";", "num_tabs", "=", "tabs", ".", "length", ";", "for", "(", ";", "i", "<", "count", ";", "i", "++", ")", "{", "if", "(", "lines", "[", "i", "]", ".", "indexOf", "(", "tabs", ")", "==", "0", ")", "{", "lines", "[", "i", "]", "=", "lines", "[", "i", "]", ".", "substr", "(", "num_tabs", ")", ";", "}", "}", "}", "lines", ".", "pop", "(", ")", ";", "result", "=", "lines", ".", "join", "(", "'\\r\\n\\t'", "+", "padding", ")", "+", "'\\r\\n'", "+", "padding", "+", "last_line", ";", "}", "return", "result", ";", "}" ]
Serialize function, then pad it's source code. Is not guaranteed to produce correct results, so may be used only for pretty-printing of source code for browser. @param {function} data @param {string} padding @returns {string}
[ "Serialize", "function", "then", "pad", "it", "s", "source", "code", ".", "Is", "not", "guaranteed", "to", "produce", "correct", "results", "so", "may", "be", "used", "only", "for", "pretty", "-", "printing", "of", "source", "code", "for", "browser", "." ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L1664-L1690
46,758
kogarashisan/LiquidLava
lib/packages/core-classes.js
function() { var old_uid = this._data_uids.pop(), old_value = this._data_values.pop(), old_name = this._data_names.pop(), count = this._count - 1; this._setLength(count); this._fire('items_removed', { uids: [old_uid], values: [old_value], names: [old_name] }); this._fire('collection_changed'); return old_value; }
javascript
function() { var old_uid = this._data_uids.pop(), old_value = this._data_values.pop(), old_name = this._data_names.pop(), count = this._count - 1; this._setLength(count); this._fire('items_removed', { uids: [old_uid], values: [old_value], names: [old_name] }); this._fire('collection_changed'); return old_value; }
[ "function", "(", ")", "{", "var", "old_uid", "=", "this", ".", "_data_uids", ".", "pop", "(", ")", ",", "old_value", "=", "this", ".", "_data_values", ".", "pop", "(", ")", ",", "old_name", "=", "this", ".", "_data_names", ".", "pop", "(", ")", ",", "count", "=", "this", ".", "_count", "-", "1", ";", "this", ".", "_setLength", "(", "count", ")", ";", "this", ".", "_fire", "(", "'items_removed'", ",", "{", "uids", ":", "[", "old_uid", "]", ",", "values", ":", "[", "old_value", "]", ",", "names", ":", "[", "old_name", "]", "}", ")", ";", "this", ".", "_fire", "(", "'collection_changed'", ")", ";", "return", "old_value", ";", "}" ]
Remove a value from the end of the collection @returns {*} Removed value
[ "Remove", "a", "value", "from", "the", "end", "of", "the", "collection" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L2019-L2037
46,759
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(value) { var result = false, index = this._data_values.indexOf(value); if (index != -1) { this.removeAt(index); result = true; } return result; }
javascript
function(value) { var result = false, index = this._data_values.indexOf(value); if (index != -1) { this.removeAt(index); result = true; } return result; }
[ "function", "(", "value", ")", "{", "var", "result", "=", "false", ",", "index", "=", "this", ".", "_data_values", ".", "indexOf", "(", "value", ")", ";", "if", "(", "index", "!=", "-", "1", ")", "{", "this", ".", "removeAt", "(", "index", ")", ";", "result", "=", "true", ";", "}", "return", "result", ";", "}" ]
Removes the first occurrence of value within collection @param {*} value @returns {boolean} <kw>true</kw>, if the value existed
[ "Removes", "the", "first", "occurrence", "of", "value", "within", "collection" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L2045-L2057
46,760
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(callback) { // everything is copied in case the collection is modified during the cycle var values = this._data_values.slice(), uids = this._data_uids.slice(), names = this._data_names.slice(), i = 0, count = this._count; for (; i < count; i++) { if (callback(values[i], names[i], uids[i], i) === false) { break; } } }
javascript
function(callback) { // everything is copied in case the collection is modified during the cycle var values = this._data_values.slice(), uids = this._data_uids.slice(), names = this._data_names.slice(), i = 0, count = this._count; for (; i < count; i++) { if (callback(values[i], names[i], uids[i], i) === false) { break; } } }
[ "function", "(", "callback", ")", "{", "// everything is copied in case the collection is modified during the cycle", "var", "values", "=", "this", ".", "_data_values", ".", "slice", "(", ")", ",", "uids", "=", "this", ".", "_data_uids", ".", "slice", "(", ")", ",", "names", "=", "this", ".", "_data_names", ".", "slice", "(", ")", ",", "i", "=", "0", ",", "count", "=", "this", ".", "_count", ";", "for", "(", ";", "i", "<", "count", ";", "i", "++", ")", "{", "if", "(", "callback", "(", "values", "[", "i", "]", ",", "names", "[", "i", "]", ",", "uids", "[", "i", "]", ",", "i", ")", "===", "false", ")", "{", "break", ";", "}", "}", "}" ]
Execute the `callback` for each item in collection @param {_tEnumerableEachCallback} callback
[ "Execute", "the", "callback", "for", "each", "item", "in", "collection" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L2083-L2100
46,761
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(new_indices) { var i = 0, result = this._createHelperStorage(), index, verification = {}; if (Lava.schema.DEBUG && new_indices.length != this._count) throw "reorder: new item count is less than current"; for (; i < this._count; i++) { index = new_indices[i]; result.push(this._data_uids[index], this._data_values[index], this._data_names[index]); if (Lava.schema.DEBUG) { // duplicate UIDs may break a lot of functionality, in this class and outside if (index in verification) Lava.t("Malformed index array"); verification[index] = null; } } this._assignStorage(result); this._fire('collection_changed'); }
javascript
function(new_indices) { var i = 0, result = this._createHelperStorage(), index, verification = {}; if (Lava.schema.DEBUG && new_indices.length != this._count) throw "reorder: new item count is less than current"; for (; i < this._count; i++) { index = new_indices[i]; result.push(this._data_uids[index], this._data_values[index], this._data_names[index]); if (Lava.schema.DEBUG) { // duplicate UIDs may break a lot of functionality, in this class and outside if (index in verification) Lava.t("Malformed index array"); verification[index] = null; } } this._assignStorage(result); this._fire('collection_changed'); }
[ "function", "(", "new_indices", ")", "{", "var", "i", "=", "0", ",", "result", "=", "this", ".", "_createHelperStorage", "(", ")", ",", "index", ",", "verification", "=", "{", "}", ";", "if", "(", "Lava", ".", "schema", ".", "DEBUG", "&&", "new_indices", ".", "length", "!=", "this", ".", "_count", ")", "throw", "\"reorder: new item count is less than current\"", ";", "for", "(", ";", "i", "<", "this", ".", "_count", ";", "i", "++", ")", "{", "index", "=", "new_indices", "[", "i", "]", ";", "result", ".", "push", "(", "this", ".", "_data_uids", "[", "index", "]", ",", "this", ".", "_data_values", "[", "index", "]", ",", "this", ".", "_data_names", "[", "index", "]", ")", ";", "if", "(", "Lava", ".", "schema", ".", "DEBUG", ")", "{", "// duplicate UIDs may break a lot of functionality, in this class and outside", "if", "(", "index", "in", "verification", ")", "Lava", ".", "t", "(", "\"Malformed index array\"", ")", ";", "verification", "[", "index", "]", "=", "null", ";", "}", "}", "this", ".", "_assignStorage", "(", "result", ")", ";", "this", ".", "_fire", "(", "'collection_changed'", ")", ";", "}" ]
Sort items by premade array of new item indices @param {Array.<number>} new_indices
[ "Sort", "items", "by", "premade", "array", "of", "new", "item", "indices" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L2195-L2220
46,762
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(start_index, count) { if (count <= 0) Lava.t("Invalid item count supplied for removeRange"); if (start_index + count >= this._count + 1) Lava.t("Index is out of range"); var removed_uids = this._data_uids.splice(start_index, count), removed_values = this._data_values.splice(start_index, count), removed_names = this._data_names.splice(start_index, count); this._setLength(this._count - count); this._fire('items_removed', { uids: removed_uids, values: removed_values, names: removed_names }); this._fire('collection_changed'); return removed_values; }
javascript
function(start_index, count) { if (count <= 0) Lava.t("Invalid item count supplied for removeRange"); if (start_index + count >= this._count + 1) Lava.t("Index is out of range"); var removed_uids = this._data_uids.splice(start_index, count), removed_values = this._data_values.splice(start_index, count), removed_names = this._data_names.splice(start_index, count); this._setLength(this._count - count); this._fire('items_removed', { uids: removed_uids, values: removed_values, names: removed_names }); this._fire('collection_changed'); return removed_values; }
[ "function", "(", "start_index", ",", "count", ")", "{", "if", "(", "count", "<=", "0", ")", "Lava", ".", "t", "(", "\"Invalid item count supplied for removeRange\"", ")", ";", "if", "(", "start_index", "+", "count", ">=", "this", ".", "_count", "+", "1", ")", "Lava", ".", "t", "(", "\"Index is out of range\"", ")", ";", "var", "removed_uids", "=", "this", ".", "_data_uids", ".", "splice", "(", "start_index", ",", "count", ")", ",", "removed_values", "=", "this", ".", "_data_values", ".", "splice", "(", "start_index", ",", "count", ")", ",", "removed_names", "=", "this", ".", "_data_names", ".", "splice", "(", "start_index", ",", "count", ")", ";", "this", ".", "_setLength", "(", "this", ".", "_count", "-", "count", ")", ";", "this", ".", "_fire", "(", "'items_removed'", ",", "{", "uids", ":", "removed_uids", ",", "values", ":", "removed_values", ",", "names", ":", "removed_names", "}", ")", ";", "this", ".", "_fire", "(", "'collection_changed'", ")", ";", "return", "removed_values", ";", "}" ]
Remove range of indices from collection and return removed values @param {number} start_index @param {number} count @returns {Array} Removed values
[ "Remove", "range", "of", "indices", "from", "collection", "and", "return", "removed", "values" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L2228-L2249
46,763
kogarashisan/LiquidLava
lib/packages/core-classes.js
function() { return { uids: [], values: [], names: [], push: function(uid, value, name) { this.uids.push(uid); this.values.push(value); this.names.push(name); }, getObject: function() { return { uids: this.uids, values: this.values, names: this.names } } } }
javascript
function() { return { uids: [], values: [], names: [], push: function(uid, value, name) { this.uids.push(uid); this.values.push(value); this.names.push(name); }, getObject: function() { return { uids: this.uids, values: this.values, names: this.names } } } }
[ "function", "(", ")", "{", "return", "{", "uids", ":", "[", "]", ",", "values", ":", "[", "]", ",", "names", ":", "[", "]", ",", "push", ":", "function", "(", "uid", ",", "value", ",", "name", ")", "{", "this", ".", "uids", ".", "push", "(", "uid", ")", ";", "this", ".", "values", ".", "push", "(", "value", ")", ";", "this", ".", "names", ".", "push", "(", "name", ")", ";", "}", ",", "getObject", ":", "function", "(", ")", "{", "return", "{", "uids", ":", "this", ".", "uids", ",", "values", ":", "this", ".", "values", ",", "names", ":", "this", ".", "names", "}", "}", "}", "}" ]
Create an internal helper object, which allows to write less code @returns {_cEnumerableHelperStorage} Helper object
[ "Create", "an", "internal", "helper", "object", "which", "allows", "to", "write", "less", "code" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L2286-L2306
46,764
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(data_source) { this.guid = Lava.guid++; if (data_source) { var count = 0, i = 0, name; if (Array.isArray(data_source)) { for (count = data_source.length; i < count; i++) { this._push(this._uid++, data_source[i], null); } } else if (data_source.isCollection) { this._data_names = data_source.getNames(); this._data_values = data_source.getValues(); for (count = this._data_values.length; i < count; i++) { this._data_uids.push(this._uid++); } } else { if (data_source.isProperties) { data_source = data_source.getProperties(); } for (name in data_source) { this._push(this._uid++, data_source[name], name); } } this._count = this._data_uids.length; } }
javascript
function(data_source) { this.guid = Lava.guid++; if (data_source) { var count = 0, i = 0, name; if (Array.isArray(data_source)) { for (count = data_source.length; i < count; i++) { this._push(this._uid++, data_source[i], null); } } else if (data_source.isCollection) { this._data_names = data_source.getNames(); this._data_values = data_source.getValues(); for (count = this._data_values.length; i < count; i++) { this._data_uids.push(this._uid++); } } else { if (data_source.isProperties) { data_source = data_source.getProperties(); } for (name in data_source) { this._push(this._uid++, data_source[name], name); } } this._count = this._data_uids.length; } }
[ "function", "(", "data_source", ")", "{", "this", ".", "guid", "=", "Lava", ".", "guid", "++", ";", "if", "(", "data_source", ")", "{", "var", "count", "=", "0", ",", "i", "=", "0", ",", "name", ";", "if", "(", "Array", ".", "isArray", "(", "data_source", ")", ")", "{", "for", "(", "count", "=", "data_source", ".", "length", ";", "i", "<", "count", ";", "i", "++", ")", "{", "this", ".", "_push", "(", "this", ".", "_uid", "++", ",", "data_source", "[", "i", "]", ",", "null", ")", ";", "}", "}", "else", "if", "(", "data_source", ".", "isCollection", ")", "{", "this", ".", "_data_names", "=", "data_source", ".", "getNames", "(", ")", ";", "this", ".", "_data_values", "=", "data_source", ".", "getValues", "(", ")", ";", "for", "(", "count", "=", "this", ".", "_data_values", ".", "length", ";", "i", "<", "count", ";", "i", "++", ")", "{", "this", ".", "_data_uids", ".", "push", "(", "this", ".", "_uid", "++", ")", ";", "}", "}", "else", "{", "if", "(", "data_source", ".", "isProperties", ")", "{", "data_source", "=", "data_source", ".", "getProperties", "(", ")", ";", "}", "for", "(", "name", "in", "data_source", ")", "{", "this", ".", "_push", "(", "this", ".", "_uid", "++", ",", "data_source", "[", "name", "]", ",", "name", ")", ";", "}", "}", "this", ".", "_count", "=", "this", ".", "_data_uids", ".", "length", ";", "}", "}" ]
Creates Enumerable instance and fills initial data from `data_source` @param {(Array|Object|Lava.mixin.Properties|Lava.system.Enumerable)} data_source
[ "Creates", "Enumerable", "instance", "and", "fills", "initial", "data", "from", "data_source" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L2369-L2417
46,765
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(data_source) { if (Lava.schema.DEBUG && typeof(data_source) != 'object') Lava.t("Wrong argument passed to updateFromSourceObject"); if (Array.isArray(data_source)) { this._updateFromArray(data_source, []); } else if (data_source.isCollection) { this._updateFromEnumerable(data_source); } else { this._updateFromObject(data_source.isProperties ? data_source.getProperties() : data_source); } }
javascript
function(data_source) { if (Lava.schema.DEBUG && typeof(data_source) != 'object') Lava.t("Wrong argument passed to updateFromSourceObject"); if (Array.isArray(data_source)) { this._updateFromArray(data_source, []); } else if (data_source.isCollection) { this._updateFromEnumerable(data_source); } else { this._updateFromObject(data_source.isProperties ? data_source.getProperties() : data_source); } }
[ "function", "(", "data_source", ")", "{", "if", "(", "Lava", ".", "schema", ".", "DEBUG", "&&", "typeof", "(", "data_source", ")", "!=", "'object'", ")", "Lava", ".", "t", "(", "\"Wrong argument passed to updateFromSourceObject\"", ")", ";", "if", "(", "Array", ".", "isArray", "(", "data_source", ")", ")", "{", "this", ".", "_updateFromArray", "(", "data_source", ",", "[", "]", ")", ";", "}", "else", "if", "(", "data_source", ".", "isCollection", ")", "{", "this", ".", "_updateFromEnumerable", "(", "data_source", ")", ";", "}", "else", "{", "this", ".", "_updateFromObject", "(", "data_source", ".", "isProperties", "?", "data_source", ".", "getProperties", "(", ")", ":", "data_source", ")", ";", "}", "}" ]
Update the collection from `data_source` @param {(Array|Object|Lava.mixin.Properties|Lava.system.Enumerable)} data_source
[ "Update", "the", "collection", "from", "data_source" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L2423-L2441
46,766
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(source_array, names) { var i = 0, count = source_array.length, items_removed_argument = { uids: this._data_uids, values: this._data_values, names: this._data_names }; this._data_uids = []; this._data_values = []; this._data_names = []; for (; i < count; i++) { this._push(this._uid++, source_array[i], names[i] || null); } this._setLength(count); this._fire('items_removed', items_removed_argument); this._fire('items_added', { uids: this._data_uids.slice(), values: this._data_values.slice(), names: this._data_names.slice() }); this._fire('collection_changed'); }
javascript
function(source_array, names) { var i = 0, count = source_array.length, items_removed_argument = { uids: this._data_uids, values: this._data_values, names: this._data_names }; this._data_uids = []; this._data_values = []; this._data_names = []; for (; i < count; i++) { this._push(this._uid++, source_array[i], names[i] || null); } this._setLength(count); this._fire('items_removed', items_removed_argument); this._fire('items_added', { uids: this._data_uids.slice(), values: this._data_values.slice(), names: this._data_names.slice() }); this._fire('collection_changed'); }
[ "function", "(", "source_array", ",", "names", ")", "{", "var", "i", "=", "0", ",", "count", "=", "source_array", ".", "length", ",", "items_removed_argument", "=", "{", "uids", ":", "this", ".", "_data_uids", ",", "values", ":", "this", ".", "_data_values", ",", "names", ":", "this", ".", "_data_names", "}", ";", "this", ".", "_data_uids", "=", "[", "]", ";", "this", ".", "_data_values", "=", "[", "]", ";", "this", ".", "_data_names", "=", "[", "]", ";", "for", "(", ";", "i", "<", "count", ";", "i", "++", ")", "{", "this", ".", "_push", "(", "this", ".", "_uid", "++", ",", "source_array", "[", "i", "]", ",", "names", "[", "i", "]", "||", "null", ")", ";", "}", "this", ".", "_setLength", "(", "count", ")", ";", "this", ".", "_fire", "(", "'items_removed'", ",", "items_removed_argument", ")", ";", "this", ".", "_fire", "(", "'items_added'", ",", "{", "uids", ":", "this", ".", "_data_uids", ".", "slice", "(", ")", ",", "values", ":", "this", ".", "_data_values", ".", "slice", "(", ")", ",", "names", ":", "this", ".", "_data_names", ".", "slice", "(", ")", "}", ")", ";", "this", ".", "_fire", "(", "'collection_changed'", ")", ";", "}" ]
Remove all current values and add values from array @param {Array} source_array @param {Array.<string>} names
[ "Remove", "all", "current", "values", "and", "add", "values", "from", "array" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L2448-L2478
46,767
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(source_object) { var i = 0, name, uid, result = this._createHelperStorage(), removed = this._createHelperStorage(), added = this._createHelperStorage(); for (; i < this._count; i++) { name = this._data_names[i]; if (name != null && (name in source_object)) { if (source_object[name] === this._data_values[i]) { result.push(this._data_uids[i], this._data_values[i], this._data_names[i]); } else { // Attention: the name has NOT changed, but it will be present in both added and removed names! removed.push(this._data_uids[i], this._data_values[i], name); uid = this._uid++; result.push(uid, source_object[name], name); added.push(uid, source_object[name], name); } } else { removed.push(this._data_uids[i], this._data_values[i], this._data_names[i]); } } for (name in source_object) { if (this._data_names.indexOf(name) == -1) { uid = this._uid++; result.push(uid, source_object[name], name); added.push(uid, source_object[name], name); } } this._assignStorage(result); this._setLength(this._data_uids.length); removed.uids.length && this._fire('items_removed', removed.getObject()); added.uids.length && this._fire('items_added', added.getObject()); this._fire('collection_changed'); }
javascript
function(source_object) { var i = 0, name, uid, result = this._createHelperStorage(), removed = this._createHelperStorage(), added = this._createHelperStorage(); for (; i < this._count; i++) { name = this._data_names[i]; if (name != null && (name in source_object)) { if (source_object[name] === this._data_values[i]) { result.push(this._data_uids[i], this._data_values[i], this._data_names[i]); } else { // Attention: the name has NOT changed, but it will be present in both added and removed names! removed.push(this._data_uids[i], this._data_values[i], name); uid = this._uid++; result.push(uid, source_object[name], name); added.push(uid, source_object[name], name); } } else { removed.push(this._data_uids[i], this._data_values[i], this._data_names[i]); } } for (name in source_object) { if (this._data_names.indexOf(name) == -1) { uid = this._uid++; result.push(uid, source_object[name], name); added.push(uid, source_object[name], name); } } this._assignStorage(result); this._setLength(this._data_uids.length); removed.uids.length && this._fire('items_removed', removed.getObject()); added.uids.length && this._fire('items_added', added.getObject()); this._fire('collection_changed'); }
[ "function", "(", "source_object", ")", "{", "var", "i", "=", "0", ",", "name", ",", "uid", ",", "result", "=", "this", ".", "_createHelperStorage", "(", ")", ",", "removed", "=", "this", ".", "_createHelperStorage", "(", ")", ",", "added", "=", "this", ".", "_createHelperStorage", "(", ")", ";", "for", "(", ";", "i", "<", "this", ".", "_count", ";", "i", "++", ")", "{", "name", "=", "this", ".", "_data_names", "[", "i", "]", ";", "if", "(", "name", "!=", "null", "&&", "(", "name", "in", "source_object", ")", ")", "{", "if", "(", "source_object", "[", "name", "]", "===", "this", ".", "_data_values", "[", "i", "]", ")", "{", "result", ".", "push", "(", "this", ".", "_data_uids", "[", "i", "]", ",", "this", ".", "_data_values", "[", "i", "]", ",", "this", ".", "_data_names", "[", "i", "]", ")", ";", "}", "else", "{", "// Attention: the name has NOT changed, but it will be present in both added and removed names!", "removed", ".", "push", "(", "this", ".", "_data_uids", "[", "i", "]", ",", "this", ".", "_data_values", "[", "i", "]", ",", "name", ")", ";", "uid", "=", "this", ".", "_uid", "++", ";", "result", ".", "push", "(", "uid", ",", "source_object", "[", "name", "]", ",", "name", ")", ";", "added", ".", "push", "(", "uid", ",", "source_object", "[", "name", "]", ",", "name", ")", ";", "}", "}", "else", "{", "removed", ".", "push", "(", "this", ".", "_data_uids", "[", "i", "]", ",", "this", ".", "_data_values", "[", "i", "]", ",", "this", ".", "_data_names", "[", "i", "]", ")", ";", "}", "}", "for", "(", "name", "in", "source_object", ")", "{", "if", "(", "this", ".", "_data_names", ".", "indexOf", "(", "name", ")", "==", "-", "1", ")", "{", "uid", "=", "this", ".", "_uid", "++", ";", "result", ".", "push", "(", "uid", ",", "source_object", "[", "name", "]", ",", "name", ")", ";", "added", ".", "push", "(", "uid", ",", "source_object", "[", "name", "]", ",", "name", ")", ";", "}", "}", "this", ".", "_assignStorage", "(", "result", ")", ";", "this", ".", "_setLength", "(", "this", ".", "_data_uids", ".", "length", ")", ";", "removed", ".", "uids", ".", "length", "&&", "this", ".", "_fire", "(", "'items_removed'", ",", "removed", ".", "getObject", "(", ")", ")", ";", "added", ".", "uids", ".", "length", "&&", "this", ".", "_fire", "(", "'items_added'", ",", "added", ".", "getObject", "(", ")", ")", ";", "this", ".", "_fire", "(", "'collection_changed'", ")", ";", "}" ]
Compares item names with object keys, removing values without names and values that do not match. Adds new values from `source_object` @param {Object} source_object
[ "Compares", "item", "names", "with", "object", "keys", "removing", "values", "without", "names", "and", "values", "that", "do", "not", "match", ".", "Adds", "new", "values", "from", "source_object" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L2495-L2550
46,768
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(index, value, name) { if (index > this._count) Lava.t("Index is out of range"); var old_uid = this._data_uids[index], old_value = this._data_values[index], old_name = this._data_names[index], new_uid = this._uid++; this._data_uids[index] = new_uid; this._data_values[index] = value; if (name) { this._data_names[index] = name; } this._fire('items_removed', { uids: [old_uid], values: [old_value], names: [old_name] }); this._fire('items_added', { uids: [new_uid], values: [value], names: [this._data_names[index]] }); this._fire('collection_changed'); }
javascript
function(index, value, name) { if (index > this._count) Lava.t("Index is out of range"); var old_uid = this._data_uids[index], old_value = this._data_values[index], old_name = this._data_names[index], new_uid = this._uid++; this._data_uids[index] = new_uid; this._data_values[index] = value; if (name) { this._data_names[index] = name; } this._fire('items_removed', { uids: [old_uid], values: [old_value], names: [old_name] }); this._fire('items_added', { uids: [new_uid], values: [value], names: [this._data_names[index]] }); this._fire('collection_changed'); }
[ "function", "(", "index", ",", "value", ",", "name", ")", "{", "if", "(", "index", ">", "this", ".", "_count", ")", "Lava", ".", "t", "(", "\"Index is out of range\"", ")", ";", "var", "old_uid", "=", "this", ".", "_data_uids", "[", "index", "]", ",", "old_value", "=", "this", ".", "_data_values", "[", "index", "]", ",", "old_name", "=", "this", ".", "_data_names", "[", "index", "]", ",", "new_uid", "=", "this", ".", "_uid", "++", ";", "this", ".", "_data_uids", "[", "index", "]", "=", "new_uid", ";", "this", ".", "_data_values", "[", "index", "]", "=", "value", ";", "if", "(", "name", ")", "{", "this", ".", "_data_names", "[", "index", "]", "=", "name", ";", "}", "this", ".", "_fire", "(", "'items_removed'", ",", "{", "uids", ":", "[", "old_uid", "]", ",", "values", ":", "[", "old_value", "]", ",", "names", ":", "[", "old_name", "]", "}", ")", ";", "this", ".", "_fire", "(", "'items_added'", ",", "{", "uids", ":", "[", "new_uid", "]", ",", "values", ":", "[", "value", "]", ",", "names", ":", "[", "this", ".", "_data_names", "[", "index", "]", "]", "}", ")", ";", "this", ".", "_fire", "(", "'collection_changed'", ")", ";", "}" ]
Replace the corresponding `value` and `name` at specified `index`, generating a new UID @param {number} index Index of value in Enumerable @param {*} value New value for given index @param {number} [name] New name for the value
[ "Replace", "the", "corresponding", "value", "and", "name", "at", "specified", "index", "generating", "a", "new", "UID" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L2572-L2601
46,769
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(value, name) { var result = false, index = this._data_values.indexOf(value); if (index == -1) { this.push(value, name); result = true; } return result; }
javascript
function(value, name) { var result = false, index = this._data_values.indexOf(value); if (index == -1) { this.push(value, name); result = true; } return result; }
[ "function", "(", "value", ",", "name", ")", "{", "var", "result", "=", "false", ",", "index", "=", "this", ".", "_data_values", ".", "indexOf", "(", "value", ")", ";", "if", "(", "index", "==", "-", "1", ")", "{", "this", ".", "push", "(", "value", ",", "name", ")", ";", "result", "=", "true", ";", "}", "return", "result", ";", "}" ]
If value does not exist - push it into collection @param {*} value New value @param {string} [name] New name @returns {boolean} <kw>true</kw>, if value did not exist and was included
[ "If", "value", "does", "not", "exist", "-", "push", "it", "into", "collection" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L2636-L2648
46,770
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(start_index, values, names) { if (start_index >= this._count) Lava.t("Index is out of range"); var i = 0, count = values.length, added_uids = [], added_names = []; if (names) { if (count != names.length) Lava.t("If names array is provided, it must be equal length with values array."); added_names = names; } else { for (; i < count; i++) { added_names.push(null); } } for (; i < count; i++) { added_uids.push(this._uid++); } if (start_index == 0) { // prepend to beginning this._data_uids = added_uids.concat(this._data_uids); this._data_values = values.concat(this._data_values); this._data_names = added_names.concat(this._data_names); } else if (start_index == this._count - 1) { // append to the end this._data_uids = this._data_uids.concat(added_uids); this._data_values = this._data_values.concat(values); this._data_names = this._data_names.concat(added_names); } else { this._data_uids = this._data_uids.slice(0, start_index).concat(added_uids).concat(this._data_uids.slice(start_index)); this._data_values = this._data_values.slice(0, start_index).concat(values).concat(this._data_values.slice(start_index)); this._data_names = this._data_names.slice(0, start_index).concat(added_names).concat(this._data_names.slice(start_index)); } this._setLength(this._count + count); this._fire('items_added', { uids: added_uids, values: values, names: added_names }); this._fire('collection_changed'); }
javascript
function(start_index, values, names) { if (start_index >= this._count) Lava.t("Index is out of range"); var i = 0, count = values.length, added_uids = [], added_names = []; if (names) { if (count != names.length) Lava.t("If names array is provided, it must be equal length with values array."); added_names = names; } else { for (; i < count; i++) { added_names.push(null); } } for (; i < count; i++) { added_uids.push(this._uid++); } if (start_index == 0) { // prepend to beginning this._data_uids = added_uids.concat(this._data_uids); this._data_values = values.concat(this._data_values); this._data_names = added_names.concat(this._data_names); } else if (start_index == this._count - 1) { // append to the end this._data_uids = this._data_uids.concat(added_uids); this._data_values = this._data_values.concat(values); this._data_names = this._data_names.concat(added_names); } else { this._data_uids = this._data_uids.slice(0, start_index).concat(added_uids).concat(this._data_uids.slice(start_index)); this._data_values = this._data_values.slice(0, start_index).concat(values).concat(this._data_values.slice(start_index)); this._data_names = this._data_names.slice(0, start_index).concat(added_names).concat(this._data_names.slice(start_index)); } this._setLength(this._count + count); this._fire('items_added', { uids: added_uids, values: values, names: added_names }); this._fire('collection_changed'); }
[ "function", "(", "start_index", ",", "values", ",", "names", ")", "{", "if", "(", "start_index", ">=", "this", ".", "_count", ")", "Lava", ".", "t", "(", "\"Index is out of range\"", ")", ";", "var", "i", "=", "0", ",", "count", "=", "values", ".", "length", ",", "added_uids", "=", "[", "]", ",", "added_names", "=", "[", "]", ";", "if", "(", "names", ")", "{", "if", "(", "count", "!=", "names", ".", "length", ")", "Lava", ".", "t", "(", "\"If names array is provided, it must be equal length with values array.\"", ")", ";", "added_names", "=", "names", ";", "}", "else", "{", "for", "(", ";", "i", "<", "count", ";", "i", "++", ")", "{", "added_names", ".", "push", "(", "null", ")", ";", "}", "}", "for", "(", ";", "i", "<", "count", ";", "i", "++", ")", "{", "added_uids", ".", "push", "(", "this", ".", "_uid", "++", ")", ";", "}", "if", "(", "start_index", "==", "0", ")", "{", "// prepend to beginning", "this", ".", "_data_uids", "=", "added_uids", ".", "concat", "(", "this", ".", "_data_uids", ")", ";", "this", ".", "_data_values", "=", "values", ".", "concat", "(", "this", ".", "_data_values", ")", ";", "this", ".", "_data_names", "=", "added_names", ".", "concat", "(", "this", ".", "_data_names", ")", ";", "}", "else", "if", "(", "start_index", "==", "this", ".", "_count", "-", "1", ")", "{", "// append to the end", "this", ".", "_data_uids", "=", "this", ".", "_data_uids", ".", "concat", "(", "added_uids", ")", ";", "this", ".", "_data_values", "=", "this", ".", "_data_values", ".", "concat", "(", "values", ")", ";", "this", ".", "_data_names", "=", "this", ".", "_data_names", ".", "concat", "(", "added_names", ")", ";", "}", "else", "{", "this", ".", "_data_uids", "=", "this", ".", "_data_uids", ".", "slice", "(", "0", ",", "start_index", ")", ".", "concat", "(", "added_uids", ")", ".", "concat", "(", "this", ".", "_data_uids", ".", "slice", "(", "start_index", ")", ")", ";", "this", ".", "_data_values", "=", "this", ".", "_data_values", ".", "slice", "(", "0", ",", "start_index", ")", ".", "concat", "(", "values", ")", ".", "concat", "(", "this", ".", "_data_values", ".", "slice", "(", "start_index", ")", ")", ";", "this", ".", "_data_names", "=", "this", ".", "_data_names", ".", "slice", "(", "0", ",", "start_index", ")", ".", "concat", "(", "added_names", ")", ".", "concat", "(", "this", ".", "_data_names", ".", "slice", "(", "start_index", ")", ")", ";", "}", "this", ".", "_setLength", "(", "this", ".", "_count", "+", "count", ")", ";", "this", ".", "_fire", "(", "'items_added'", ",", "{", "uids", ":", "added_uids", ",", "values", ":", "values", ",", "names", ":", "added_names", "}", ")", ";", "this", ".", "_fire", "(", "'collection_changed'", ")", ";", "}" ]
Insert a sequence of values into collection @param {number} start_index Index of the beginning of new values. Must be less or equal to collection's `_count` @param {Array.<*>} values New values @param [names] Names that correspond to each value
[ "Insert", "a", "sequence", "of", "values", "into", "collection" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L2656-L2718
46,771
kogarashisan/LiquidLava
lib/packages/core-classes.js
function() { this._data_names = this._data_source.getNames(); this._data_values = this._data_source.getValues(); this._data_uids = this._data_source.getUIDs(); this._count = this._data_uids.length; this._fire('collection_changed'); }
javascript
function() { this._data_names = this._data_source.getNames(); this._data_values = this._data_source.getValues(); this._data_uids = this._data_source.getUIDs(); this._count = this._data_uids.length; this._fire('collection_changed'); }
[ "function", "(", ")", "{", "this", ".", "_data_names", "=", "this", ".", "_data_source", ".", "getNames", "(", ")", ";", "this", ".", "_data_values", "=", "this", ".", "_data_source", ".", "getValues", "(", ")", ";", "this", ".", "_data_uids", "=", "this", ".", "_data_source", ".", "getUIDs", "(", ")", ";", "this", ".", "_count", "=", "this", ".", "_data_uids", ".", "length", ";", "this", ".", "_fire", "(", "'collection_changed'", ")", ";", "}" ]
Refresh the DataView from it's Enumerable
[ "Refresh", "the", "DataView", "from", "it", "s", "Enumerable" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L2796-L2804
46,772
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(data_source) { if (Lava.schema.DEBUG && !data_source.isCollection) Lava.t("Wrong argument supplied for DataView constructor"); this._data_source = data_source; }
javascript
function(data_source) { if (Lava.schema.DEBUG && !data_source.isCollection) Lava.t("Wrong argument supplied for DataView constructor"); this._data_source = data_source; }
[ "function", "(", "data_source", ")", "{", "if", "(", "Lava", ".", "schema", ".", "DEBUG", "&&", "!", "data_source", ".", "isCollection", ")", "Lava", ".", "t", "(", "\"Wrong argument supplied for DataView constructor\"", ")", ";", "this", ".", "_data_source", "=", "data_source", ";", "}" ]
Set new `_data_source` @param {Lava.system.CollectionAbstract} data_source
[ "Set", "new", "_data_source" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L2810-L2815
46,773
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(template_config, widget, parent_view, child_properties) { this.guid = Lava.guid++; this._parent_view = parent_view; this._widget = widget; this._config = template_config; this._createChildren(this._content, template_config, [], child_properties); this._count = this._content.length; }
javascript
function(template_config, widget, parent_view, child_properties) { this.guid = Lava.guid++; this._parent_view = parent_view; this._widget = widget; this._config = template_config; this._createChildren(this._content, template_config, [], child_properties); this._count = this._content.length; }
[ "function", "(", "template_config", ",", "widget", ",", "parent_view", ",", "child_properties", ")", "{", "this", ".", "guid", "=", "Lava", ".", "guid", "++", ";", "this", ".", "_parent_view", "=", "parent_view", ";", "this", ".", "_widget", "=", "widget", ";", "this", ".", "_config", "=", "template_config", ";", "this", ".", "_createChildren", "(", "this", ".", "_content", ",", "template_config", ",", "[", "]", ",", "child_properties", ")", ";", "this", ".", "_count", "=", "this", ".", "_content", ".", "length", ";", "}" ]
Create an instance of Template. Create content from config @param {_tTemplate} template_config Config for content @param {Lava.widget.Standard} widget Nearest widget in hierarchy @param {Lava.view.Abstract} parent_view Owner (parent) view @param {Object} [child_properties] The properties to set to child views
[ "Create", "an", "instance", "of", "Template", ".", "Create", "content", "from", "config" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L2915-L2925
46,774
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(result, children_config, include_name_stack, properties) { var i = 0, count = children_config.length, childConfig, type; for (; i < count; i++) { childConfig = children_config[i]; type = typeof(childConfig); if (type == 'object') type = childConfig.type; if (Lava.schema.DEBUG && !(type in this._block_handlers_map)) Lava.t("Unsupported template item type: " + type); this[this._block_handlers_map[type]](result, childConfig, include_name_stack, properties); } }
javascript
function(result, children_config, include_name_stack, properties) { var i = 0, count = children_config.length, childConfig, type; for (; i < count; i++) { childConfig = children_config[i]; type = typeof(childConfig); if (type == 'object') type = childConfig.type; if (Lava.schema.DEBUG && !(type in this._block_handlers_map)) Lava.t("Unsupported template item type: " + type); this[this._block_handlers_map[type]](result, childConfig, include_name_stack, properties); } }
[ "function", "(", "result", ",", "children_config", ",", "include_name_stack", ",", "properties", ")", "{", "var", "i", "=", "0", ",", "count", "=", "children_config", ".", "length", ",", "childConfig", ",", "type", ";", "for", "(", ";", "i", "<", "count", ";", "i", "++", ")", "{", "childConfig", "=", "children_config", "[", "i", "]", ";", "type", "=", "typeof", "(", "childConfig", ")", ";", "if", "(", "type", "==", "'object'", ")", "type", "=", "childConfig", ".", "type", ";", "if", "(", "Lava", ".", "schema", ".", "DEBUG", "&&", "!", "(", "type", "in", "this", ".", "_block_handlers_map", ")", ")", "Lava", ".", "t", "(", "\"Unsupported template item type: \"", "+", "type", ")", ";", "this", "[", "this", ".", "_block_handlers_map", "[", "type", "]", "]", "(", "result", ",", "childConfig", ",", "include_name_stack", ",", "properties", ")", ";", "}", "}" ]
Create items from config and put them in `result` @param {Array.<_tRenderable>} result Where to put created items @param {_tTemplate} children_config Config for the Template @param {Array.<string>} include_name_stack Used to protect from recursive includes @param {Object} properties The properties for child views
[ "Create", "items", "from", "config", "and", "put", "them", "in", "result" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L2934-L2952
46,775
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(result, childConfig, include_name_stack, properties) { var constructor = Lava.ClassManager.getConstructor(childConfig['class'], 'Lava.view'), view = new constructor( childConfig, this._widget, this._parent_view, this, // template properties ); view.template_index = result.push(view) - 1; }
javascript
function(result, childConfig, include_name_stack, properties) { var constructor = Lava.ClassManager.getConstructor(childConfig['class'], 'Lava.view'), view = new constructor( childConfig, this._widget, this._parent_view, this, // template properties ); view.template_index = result.push(view) - 1; }
[ "function", "(", "result", ",", "childConfig", ",", "include_name_stack", ",", "properties", ")", "{", "var", "constructor", "=", "Lava", ".", "ClassManager", ".", "getConstructor", "(", "childConfig", "[", "'class'", "]", ",", "'Lava.view'", ")", ",", "view", "=", "new", "constructor", "(", "childConfig", ",", "this", ".", "_widget", ",", "this", ".", "_parent_view", ",", "this", ",", "// template", "properties", ")", ";", "view", ".", "template_index", "=", "result", ".", "push", "(", "view", ")", "-", "1", ";", "}" ]
Handler for views. Create a view and push it into result @param {Array.<_tRenderable>} result @param {(_cView|_cWidget)} childConfig Config vor the view @param {Array.<string>} include_name_stack Used to protect from recursive includes @param {Object} properties Properties for that view
[ "Handler", "for", "views", ".", "Create", "a", "view", "and", "push", "it", "into", "result" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L2972-L2985
46,776
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(result, child_config, include_name_stack, properties) { if (include_name_stack.indexOf(child_config.name) != -1) Lava.t("Infinite include recursion"); var include = Lava.view_manager.getInclude(this._parent_view, child_config); if (Lava.schema.DEBUG && include == null) Lava.t("Include not found: " + child_config.name); include_name_stack.push(child_config.name); this._createChildren(result, include, include_name_stack, properties); include_name_stack.pop(); }
javascript
function(result, child_config, include_name_stack, properties) { if (include_name_stack.indexOf(child_config.name) != -1) Lava.t("Infinite include recursion"); var include = Lava.view_manager.getInclude(this._parent_view, child_config); if (Lava.schema.DEBUG && include == null) Lava.t("Include not found: " + child_config.name); include_name_stack.push(child_config.name); this._createChildren(result, include, include_name_stack, properties); include_name_stack.pop(); }
[ "function", "(", "result", ",", "child_config", ",", "include_name_stack", ",", "properties", ")", "{", "if", "(", "include_name_stack", ".", "indexOf", "(", "child_config", ".", "name", ")", "!=", "-", "1", ")", "Lava", ".", "t", "(", "\"Infinite include recursion\"", ")", ";", "var", "include", "=", "Lava", ".", "view_manager", ".", "getInclude", "(", "this", ".", "_parent_view", ",", "child_config", ")", ";", "if", "(", "Lava", ".", "schema", ".", "DEBUG", "&&", "include", "==", "null", ")", "Lava", ".", "t", "(", "\"Include not found: \"", "+", "child_config", ".", "name", ")", ";", "include_name_stack", ".", "push", "(", "child_config", ".", "name", ")", ";", "this", ".", "_createChildren", "(", "result", ",", "include", ",", "include_name_stack", ",", "properties", ")", ";", "include_name_stack", ".", "pop", "(", ")", ";", "}" ]
Handler for includes. Get include from widget, then create and append all items from include @param {Array.<_tRenderable>} result @param {_cInclude} child_config @param {Array.<string>} include_name_stack @param {Object} properties
[ "Handler", "for", "includes", ".", "Get", "include", "from", "widget", "then", "create", "and", "append", "all", "items", "from", "include" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L2994-L3004
46,777
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(name, value) { for (var i = 0; i < this._count; i++) { if (this._content[i].isView) { this._content[i].set(name, value); } } }
javascript
function(name, value) { for (var i = 0; i < this._count; i++) { if (this._content[i].isView) { this._content[i].set(name, value); } } }
[ "function", "(", "name", ",", "value", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "this", ".", "_count", ";", "i", "++", ")", "{", "if", "(", "this", ".", "_content", "[", "i", "]", ".", "isView", ")", "{", "this", ".", "_content", "[", "i", "]", ".", "set", "(", "name", ",", "value", ")", ";", "}", "}", "}" ]
Set this property to all views inside `_content` @param {string} name Property name @param {*} value Property value
[ "Set", "this", "property", "to", "all", "views", "inside", "_content" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L3199-L3211
46,778
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(properties_object) { for (var i = 0; i < this._count; i++) { if (this._content[i].isView) { this._content[i].setProperties(properties_object); } } }
javascript
function(properties_object) { for (var i = 0; i < this._count; i++) { if (this._content[i].isView) { this._content[i].setProperties(properties_object); } } }
[ "function", "(", "properties_object", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "this", ".", "_count", ";", "i", "++", ")", "{", "if", "(", "this", ".", "_content", "[", "i", "]", ".", "isView", ")", "{", "this", ".", "_content", "[", "i", "]", ".", "setProperties", "(", "properties_object", ")", ";", "}", "}", "}" ]
Set properties to all views inside `_content` @param {Object} properties_object
[ "Set", "properties", "to", "all", "views", "inside", "_content" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L3217-L3229
46,779
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(i) { var result = null; while (i < this._count) { if (this._content[i].isView) { result = this._content[i]; break; } i++; } return result; }
javascript
function(i) { var result = null; while (i < this._count) { if (this._content[i].isView) { result = this._content[i]; break; } i++; } return result; }
[ "function", "(", "i", ")", "{", "var", "result", "=", "null", ";", "while", "(", "i", "<", "this", ".", "_count", ")", "{", "if", "(", "this", ".", "_content", "[", "i", "]", ".", "isView", ")", "{", "result", "=", "this", ".", "_content", "[", "i", "]", ";", "break", ";", "}", "i", "++", ";", "}", "return", "result", ";", "}" ]
Algorithm to find next view @returns {Lava.view.Abstract} Next view from index `i`
[ "Algorithm", "to", "find", "next", "view" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L3277-L3291
46,780
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(label) { var result = [], i = 0; for (; i < this._count; i++) { if (this._content[i].isView && this._content[i].label == label) { result.push(this._content[i]); } } return result; }
javascript
function(label) { var result = [], i = 0; for (; i < this._count; i++) { if (this._content[i].isView && this._content[i].label == label) { result.push(this._content[i]); } } return result; }
[ "function", "(", "label", ")", "{", "var", "result", "=", "[", "]", ",", "i", "=", "0", ";", "for", "(", ";", "i", "<", "this", ".", "_count", ";", "i", "++", ")", "{", "if", "(", "this", ".", "_content", "[", "i", "]", ".", "isView", "&&", "this", ".", "_content", "[", "i", "]", ".", "label", "==", "label", ")", "{", "result", ".", "push", "(", "this", ".", "_content", "[", "i", "]", ")", ";", "}", "}", "return", "result", ";", "}" ]
Search `_content` and find all views with given label @param {string} label Label to search for @returns {Array.<Lava.view.Abstract>} Views with given label
[ "Search", "_content", "and", "find", "all", "views", "with", "given", "label" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L3318-L3335
46,781
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(name) { var result = [], i = 0; for (; i < this._count; i++) { if (this._content[i].isWidget && this._content[i].name == name) { result.push(this._content[i]); } } return result; }
javascript
function(name) { var result = [], i = 0; for (; i < this._count; i++) { if (this._content[i].isWidget && this._content[i].name == name) { result.push(this._content[i]); } } return result; }
[ "function", "(", "name", ")", "{", "var", "result", "=", "[", "]", ",", "i", "=", "0", ";", "for", "(", ";", "i", "<", "this", ".", "_count", ";", "i", "++", ")", "{", "if", "(", "this", ".", "_content", "[", "i", "]", ".", "isWidget", "&&", "this", ".", "_content", "[", "i", "]", ".", "name", "==", "name", ")", "{", "result", ".", "push", "(", "this", ".", "_content", "[", "i", "]", ")", ";", "}", "}", "return", "result", ";", "}" ]
Find all widgets with given name inside `_content` @param {string} name Name to search for @returns {Array.<Lava.widget.Standard>} Found widgets
[ "Find", "all", "widgets", "with", "given", "name", "inside", "_content" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L3342-L3359
46,782
kogarashisan/LiquidLava
lib/packages/core-classes.js
function() { var default_events = Lava.schema.system.DEFAULT_EVENTS, i = 0, count = default_events.length; for (; i < count; i++) { this._event_usage_counters[default_events[i]] = 1; this._initEvent(default_events[i]); } }
javascript
function() { var default_events = Lava.schema.system.DEFAULT_EVENTS, i = 0, count = default_events.length; for (; i < count; i++) { this._event_usage_counters[default_events[i]] = 1; this._initEvent(default_events[i]); } }
[ "function", "(", ")", "{", "var", "default_events", "=", "Lava", ".", "schema", ".", "system", ".", "DEFAULT_EVENTS", ",", "i", "=", "0", ",", "count", "=", "default_events", ".", "length", ";", "for", "(", ";", "i", "<", "count", ";", "i", "++", ")", "{", "this", ".", "_event_usage_counters", "[", "default_events", "[", "i", "]", "]", "=", "1", ";", "this", ".", "_initEvent", "(", "default_events", "[", "i", "]", ")", ";", "}", "}" ]
Create an instance of the class, acquire event listeners
[ "Create", "an", "instance", "of", "the", "class", "acquire", "event", "listeners" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L3514-L3527
46,783
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(view) { if (view.depth in this._dirty_views) { this._dirty_views[view.depth].push(view); } else { this._dirty_views[view.depth] = [view]; } }
javascript
function(view) { if (view.depth in this._dirty_views) { this._dirty_views[view.depth].push(view); } else { this._dirty_views[view.depth] = [view]; } }
[ "function", "(", "view", ")", "{", "if", "(", "view", ".", "depth", "in", "this", ".", "_dirty_views", ")", "{", "this", ".", "_dirty_views", "[", "view", ".", "depth", "]", ".", "push", "(", "view", ")", ";", "}", "else", "{", "this", ".", "_dirty_views", "[", "view", ".", "depth", "]", "=", "[", "view", "]", ";", "}", "}" ]
Place a view into queue for refresh @param {Lava.view.Abstract} view
[ "Place", "a", "view", "into", "queue", "for", "refresh" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L3533-L3545
46,784
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(dirty_views) { var level = 0, deepness, views_list, has_exceptions = false, i, count; deepness = dirty_views.length; // this line must be after ScopeManager#refresh() for (; level < deepness; level++) { if (level in dirty_views) { views_list = dirty_views[level]; for (i = 0, count = views_list.length; i < count; i++) { if (views_list[i].refresh(this._refresh_id)) { Lava.logError("ViewManager: view was refreshed several times in one refresh loop. Aborting."); has_exceptions = true; } } } } return has_exceptions; }
javascript
function(dirty_views) { var level = 0, deepness, views_list, has_exceptions = false, i, count; deepness = dirty_views.length; // this line must be after ScopeManager#refresh() for (; level < deepness; level++) { if (level in dirty_views) { views_list = dirty_views[level]; for (i = 0, count = views_list.length; i < count; i++) { if (views_list[i].refresh(this._refresh_id)) { Lava.logError("ViewManager: view was refreshed several times in one refresh loop. Aborting."); has_exceptions = true; } } } } return has_exceptions; }
[ "function", "(", "dirty_views", ")", "{", "var", "level", "=", "0", ",", "deepness", ",", "views_list", ",", "has_exceptions", "=", "false", ",", "i", ",", "count", ";", "deepness", "=", "dirty_views", ".", "length", ";", "// this line must be after ScopeManager#refresh()", "for", "(", ";", "level", "<", "deepness", ";", "level", "++", ")", "{", "if", "(", "level", "in", "dirty_views", ")", "{", "views_list", "=", "dirty_views", "[", "level", "]", ";", "for", "(", "i", "=", "0", ",", "count", "=", "views_list", ".", "length", ";", "i", "<", "count", ";", "i", "++", ")", "{", "if", "(", "views_list", "[", "i", "]", ".", "refresh", "(", "this", ".", "_refresh_id", ")", ")", "{", "Lava", ".", "logError", "(", "\"ViewManager: view was refreshed several times in one refresh loop. Aborting.\"", ")", ";", "has_exceptions", "=", "true", ";", "}", "}", "}", "}", "return", "has_exceptions", ";", "}" ]
Repeatable callback, that performs refresh of dirty views @param {Array.<Array.<Lava.view.Abstract>>} dirty_views
[ "Repeatable", "callback", "that", "performs", "refresh", "of", "dirty", "views" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L3588-L3620
46,785
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(starting_widget, id) { if (Lava.schema.DEBUG && !id) Lava.t(); return this._views_by_id[id]; }
javascript
function(starting_widget, id) { if (Lava.schema.DEBUG && !id) Lava.t(); return this._views_by_id[id]; }
[ "function", "(", "starting_widget", ",", "id", ")", "{", "if", "(", "Lava", ".", "schema", ".", "DEBUG", "&&", "!", "id", ")", "Lava", ".", "t", "(", ")", ";", "return", "this", ".", "_views_by_id", "[", "id", "]", ";", "}" ]
Get widget by id. Does not take hierarchy into account @param {Lava.widget.Standard} starting_widget @param {string} id @returns {Lava.view.Abstract}
[ "Get", "widget", "by", "id", ".", "Does", "not", "take", "hierarchy", "into", "account" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L3693-L3699
46,786
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(starting_widget, guid) { if (Lava.schema.DEBUG && !guid) Lava.t(); return this._views_by_guid[guid]; }
javascript
function(starting_widget, guid) { if (Lava.schema.DEBUG && !guid) Lava.t(); return this._views_by_guid[guid]; }
[ "function", "(", "starting_widget", ",", "guid", ")", "{", "if", "(", "Lava", ".", "schema", ".", "DEBUG", "&&", "!", "guid", ")", "Lava", ".", "t", "(", ")", ";", "return", "this", ".", "_views_by_guid", "[", "guid", "]", ";", "}" ]
Get widget by GUID. Does not consider hierarchy @param {Lava.widget.Standard} starting_widget @param {_tGUID} guid @returns {Lava.view.Abstract}
[ "Get", "widget", "by", "GUID", ".", "Does", "not", "consider", "hierarchy" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L3707-L3713
46,787
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(view, targets, callback, callback_arguments, global_targets_object) { var i = 0, count = targets.length, target, target_name, widget, template_arguments, bubble_index = 0, bubble_targets_copy, bubble_targets_count; this._nested_dispatch_count++; for (; i < count; i++) { target = targets[i]; target_name = target.name; template_arguments = ('arguments' in target) ? this._evalTargetArguments(view, target) : null; widget = null; if ('locator_type' in target) { /* Note: there is similar view location mechanism in view.Abstract, but the algorithms are different: when ViewManager seeks by label - it searches only for widgets, while view checks all views in hierarchy. Also, hardcoded labels differ. */ widget = this['_locateWidgetBy' + target.locator_type](view.getWidget(), target.locator); if (!widget) { Lava.logError('ViewManager: callback target (widget) not found. Type: ' + target.locator_type + ', locator: ' + target.locator); } else if (!widget.isWidget) { Lava.logError('ViewManager: callback target is not a widget'); } else if (!callback(widget, target_name, view, template_arguments, callback_arguments)) { Lava.logError('ViewManager: targeted widget did not handle the role or event: ' + target_name); } // ignore possible call to cancelBubble() this._cancel_bubble = false; } else { // bubble widget = view.getWidget(); do { callback(widget, target_name, view, template_arguments, callback_arguments); widget = widget.getParentWidget(); } while (widget && !this._cancel_bubble); if (this._cancel_bubble) { this._cancel_bubble = false; continue; } if (target_name in global_targets_object) { // cause target can be removed inside event handler bubble_targets_copy = global_targets_object[target_name].slice(); for (bubble_targets_count = bubble_targets_copy.length; bubble_index < bubble_targets_count; bubble_index++) { callback( bubble_targets_copy[bubble_index], target_name, view, template_arguments, callback_arguments ); if (this._cancel_bubble) { this._cancel_bubble = false; break; } } } } } this._nested_dispatch_count--; }
javascript
function(view, targets, callback, callback_arguments, global_targets_object) { var i = 0, count = targets.length, target, target_name, widget, template_arguments, bubble_index = 0, bubble_targets_copy, bubble_targets_count; this._nested_dispatch_count++; for (; i < count; i++) { target = targets[i]; target_name = target.name; template_arguments = ('arguments' in target) ? this._evalTargetArguments(view, target) : null; widget = null; if ('locator_type' in target) { /* Note: there is similar view location mechanism in view.Abstract, but the algorithms are different: when ViewManager seeks by label - it searches only for widgets, while view checks all views in hierarchy. Also, hardcoded labels differ. */ widget = this['_locateWidgetBy' + target.locator_type](view.getWidget(), target.locator); if (!widget) { Lava.logError('ViewManager: callback target (widget) not found. Type: ' + target.locator_type + ', locator: ' + target.locator); } else if (!widget.isWidget) { Lava.logError('ViewManager: callback target is not a widget'); } else if (!callback(widget, target_name, view, template_arguments, callback_arguments)) { Lava.logError('ViewManager: targeted widget did not handle the role or event: ' + target_name); } // ignore possible call to cancelBubble() this._cancel_bubble = false; } else { // bubble widget = view.getWidget(); do { callback(widget, target_name, view, template_arguments, callback_arguments); widget = widget.getParentWidget(); } while (widget && !this._cancel_bubble); if (this._cancel_bubble) { this._cancel_bubble = false; continue; } if (target_name in global_targets_object) { // cause target can be removed inside event handler bubble_targets_copy = global_targets_object[target_name].slice(); for (bubble_targets_count = bubble_targets_copy.length; bubble_index < bubble_targets_count; bubble_index++) { callback( bubble_targets_copy[bubble_index], target_name, view, template_arguments, callback_arguments ); if (this._cancel_bubble) { this._cancel_bubble = false; break; } } } } } this._nested_dispatch_count--; }
[ "function", "(", "view", ",", "targets", ",", "callback", ",", "callback_arguments", ",", "global_targets_object", ")", "{", "var", "i", "=", "0", ",", "count", "=", "targets", ".", "length", ",", "target", ",", "target_name", ",", "widget", ",", "template_arguments", ",", "bubble_index", "=", "0", ",", "bubble_targets_copy", ",", "bubble_targets_count", ";", "this", ".", "_nested_dispatch_count", "++", ";", "for", "(", ";", "i", "<", "count", ";", "i", "++", ")", "{", "target", "=", "targets", "[", "i", "]", ";", "target_name", "=", "target", ".", "name", ";", "template_arguments", "=", "(", "'arguments'", "in", "target", ")", "?", "this", ".", "_evalTargetArguments", "(", "view", ",", "target", ")", ":", "null", ";", "widget", "=", "null", ";", "if", "(", "'locator_type'", "in", "target", ")", "{", "/*\n\t\t\t\t Note: there is similar view location mechanism in view.Abstract, but the algorithms are different:\n\t\t\t\t when ViewManager seeks by label - it searches only for widgets, while view checks all views in hierarchy.\n\t\t\t\t Also, hardcoded labels differ.\n\t\t\t\t */", "widget", "=", "this", "[", "'_locateWidgetBy'", "+", "target", ".", "locator_type", "]", "(", "view", ".", "getWidget", "(", ")", ",", "target", ".", "locator", ")", ";", "if", "(", "!", "widget", ")", "{", "Lava", ".", "logError", "(", "'ViewManager: callback target (widget) not found. Type: '", "+", "target", ".", "locator_type", "+", "', locator: '", "+", "target", ".", "locator", ")", ";", "}", "else", "if", "(", "!", "widget", ".", "isWidget", ")", "{", "Lava", ".", "logError", "(", "'ViewManager: callback target is not a widget'", ")", ";", "}", "else", "if", "(", "!", "callback", "(", "widget", ",", "target_name", ",", "view", ",", "template_arguments", ",", "callback_arguments", ")", ")", "{", "Lava", ".", "logError", "(", "'ViewManager: targeted widget did not handle the role or event: '", "+", "target_name", ")", ";", "}", "// ignore possible call to cancelBubble()", "this", ".", "_cancel_bubble", "=", "false", ";", "}", "else", "{", "// bubble", "widget", "=", "view", ".", "getWidget", "(", ")", ";", "do", "{", "callback", "(", "widget", ",", "target_name", ",", "view", ",", "template_arguments", ",", "callback_arguments", ")", ";", "widget", "=", "widget", ".", "getParentWidget", "(", ")", ";", "}", "while", "(", "widget", "&&", "!", "this", ".", "_cancel_bubble", ")", ";", "if", "(", "this", ".", "_cancel_bubble", ")", "{", "this", ".", "_cancel_bubble", "=", "false", ";", "continue", ";", "}", "if", "(", "target_name", "in", "global_targets_object", ")", "{", "// cause target can be removed inside event handler", "bubble_targets_copy", "=", "global_targets_object", "[", "target_name", "]", ".", "slice", "(", ")", ";", "for", "(", "bubble_targets_count", "=", "bubble_targets_copy", ".", "length", ";", "bubble_index", "<", "bubble_targets_count", ";", "bubble_index", "++", ")", "{", "callback", "(", "bubble_targets_copy", "[", "bubble_index", "]", ",", "target_name", ",", "view", ",", "template_arguments", ",", "callback_arguments", ")", ";", "if", "(", "this", ".", "_cancel_bubble", ")", "{", "this", ".", "_cancel_bubble", "=", "false", ";", "break", ";", "}", "}", "}", "}", "}", "this", ".", "_nested_dispatch_count", "--", ";", "}" ]
Dispatch events and roles to their targets. Warning! Violates codestyle with multiple return statements @param {Lava.view.Abstract} view The source of events or roles @param {Array.<_cTarget>} targets The target routes @param {function} callback The ViewManager callback that will perform dispatching @param {*} callback_arguments Will be passed to `callback` @param {Object.<string, Array>} global_targets_object Either {@link Lava.system.ViewManager#_global_role_targets} or {@link Lava.system.ViewManager#_global_event_targets}
[ "Dispatch", "events", "and", "roles", "to", "their", "targets", ".", "Warning!", "Violates", "codestyle", "with", "multiple", "return", "statements" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L3795-L3888
46,788
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(view, event_name, event_object) { var targets = view.getContainer().getEventTargets(event_name); if (targets) { this.dispatchEvent(view, event_name, event_object, targets); } }
javascript
function(view, event_name, event_object) { var targets = view.getContainer().getEventTargets(event_name); if (targets) { this.dispatchEvent(view, event_name, event_object, targets); } }
[ "function", "(", "view", ",", "event_name", ",", "event_object", ")", "{", "var", "targets", "=", "view", ".", "getContainer", "(", ")", ".", "getEventTargets", "(", "event_name", ")", ";", "if", "(", "targets", ")", "{", "this", ".", "dispatchEvent", "(", "view", ",", "event_name", ",", "event_object", ",", "targets", ")", ";", "}", "}" ]
Helper method which checks for events presence on container and dispatches them @param {Lava.view.Abstract} view @param {string} event_name @param {Object} event_object
[ "Helper", "method", "which", "checks", "for", "events", "presence", "on", "container", "and", "dispatches", "them" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L3949-L3959
46,789
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(view, event_name, event_object, targets) { this._dispatchCallback( view, targets, this._callHandleEvent, { event_name: event_name, event_object: event_object }, this._global_event_targets ); }
javascript
function(view, event_name, event_object, targets) { this._dispatchCallback( view, targets, this._callHandleEvent, { event_name: event_name, event_object: event_object }, this._global_event_targets ); }
[ "function", "(", "view", ",", "event_name", ",", "event_object", ",", "targets", ")", "{", "this", ".", "_dispatchCallback", "(", "view", ",", "targets", ",", "this", ".", "_callHandleEvent", ",", "{", "event_name", ":", "event_name", ",", "event_object", ":", "event_object", "}", ",", "this", ".", "_global_event_targets", ")", ";", "}" ]
Dispatch DOM events to targets @param {Lava.view.Abstract} view View, that owns the container, which raised the events @param {string} event_name @param {Object} event_object DOM event object @param {Array.<_cTarget>} targets
[ "Dispatch", "DOM", "events", "to", "targets" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L3969-L3982
46,790
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(view, target) { var result = []; for (var i = 0, count = target.arguments.length; i < count; i++) { if (target.arguments[i].type == Lava.TARGET_ARGUMENT_TYPES.VALUE) { result.push(target.arguments[i].data); } else { if (target.arguments[i].type != Lava.TARGET_ARGUMENT_TYPES.BIND) Lava.t(); result.push(view.evalPathConfig(target.arguments[i].data)); } } return result; }
javascript
function(view, target) { var result = []; for (var i = 0, count = target.arguments.length; i < count; i++) { if (target.arguments[i].type == Lava.TARGET_ARGUMENT_TYPES.VALUE) { result.push(target.arguments[i].data); } else { if (target.arguments[i].type != Lava.TARGET_ARGUMENT_TYPES.BIND) Lava.t(); result.push(view.evalPathConfig(target.arguments[i].data)); } } return result; }
[ "function", "(", "view", ",", "target", ")", "{", "var", "result", "=", "[", "]", ";", "for", "(", "var", "i", "=", "0", ",", "count", "=", "target", ".", "arguments", ".", "length", ";", "i", "<", "count", ";", "i", "++", ")", "{", "if", "(", "target", ".", "arguments", "[", "i", "]", ".", "type", "==", "Lava", ".", "TARGET_ARGUMENT_TYPES", ".", "VALUE", ")", "{", "result", ".", "push", "(", "target", ".", "arguments", "[", "i", "]", ".", "data", ")", ";", "}", "else", "{", "if", "(", "target", ".", "arguments", "[", "i", "]", ".", "type", "!=", "Lava", ".", "TARGET_ARGUMENT_TYPES", ".", "BIND", ")", "Lava", ".", "t", "(", ")", ";", "result", ".", "push", "(", "view", ".", "evalPathConfig", "(", "target", ".", "arguments", "[", "i", "]", ".", "data", ")", ")", ";", "}", "}", "return", "result", ";", "}" ]
Evaluate template arguments @param {Lava.view.Abstract} view @param {_cTarget} target @returns {Array.<*>}
[ "Evaluate", "template", "arguments" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L3990-L4012
46,791
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(starting_view, config) { var widget = starting_view.getWidget(), template_arguments = ('arguments' in config) ? this._evalTargetArguments(starting_view, config) : null; if ('locator_type' in config) { widget = this['_locateWidgetBy' + config.locator_type](widget, config.locator); if (!widget || !widget.isWidget) Lava.t(); } return widget.getInclude(config.name, template_arguments); }
javascript
function(starting_view, config) { var widget = starting_view.getWidget(), template_arguments = ('arguments' in config) ? this._evalTargetArguments(starting_view, config) : null; if ('locator_type' in config) { widget = this['_locateWidgetBy' + config.locator_type](widget, config.locator); if (!widget || !widget.isWidget) Lava.t(); } return widget.getInclude(config.name, template_arguments); }
[ "function", "(", "starting_view", ",", "config", ")", "{", "var", "widget", "=", "starting_view", ".", "getWidget", "(", ")", ",", "template_arguments", "=", "(", "'arguments'", "in", "config", ")", "?", "this", ".", "_evalTargetArguments", "(", "starting_view", ",", "config", ")", ":", "null", ";", "if", "(", "'locator_type'", "in", "config", ")", "{", "widget", "=", "this", "[", "'_locateWidgetBy'", "+", "config", ".", "locator_type", "]", "(", "widget", ",", "config", ".", "locator", ")", ";", "if", "(", "!", "widget", "||", "!", "widget", ".", "isWidget", ")", "Lava", ".", "t", "(", ")", ";", "}", "return", "widget", ".", "getInclude", "(", "config", ".", "name", ",", "template_arguments", ")", ";", "}" ]
Get include from widget @param {Lava.view.Abstract} starting_view @param {_cInclude} config @returns {_tTemplate}
[ "Get", "include", "from", "widget" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L4020-L4035
46,792
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(element) { var id = Firestorm.Element.getProperty(element, 'id'), result = null; if (id) { if (id.indexOf(Lava.ELEMENT_ID_PREFIX) == 0) { result = this.getViewByGuid(id.substr(Lava.ELEMENT_ID_PREFIX.length)); } } return result; }
javascript
function(element) { var id = Firestorm.Element.getProperty(element, 'id'), result = null; if (id) { if (id.indexOf(Lava.ELEMENT_ID_PREFIX) == 0) { result = this.getViewByGuid(id.substr(Lava.ELEMENT_ID_PREFIX.length)); } } return result; }
[ "function", "(", "element", ")", "{", "var", "id", "=", "Firestorm", ".", "Element", ".", "getProperty", "(", "element", ",", "'id'", ")", ",", "result", "=", "null", ";", "if", "(", "id", ")", "{", "if", "(", "id", ".", "indexOf", "(", "Lava", ".", "ELEMENT_ID_PREFIX", ")", "==", "0", ")", "{", "result", "=", "this", ".", "getViewByGuid", "(", "id", ".", "substr", "(", "Lava", ".", "ELEMENT_ID_PREFIX", ".", "length", ")", ")", ";", "}", "}", "return", "result", ";", "}" ]
Get the view, the container of which owns the given element @param {HTMLElement} element @returns {Lava.view.Abstract}
[ "Get", "the", "view", "the", "container", "of", "which", "owns", "the", "given", "element" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L4134-L4151
46,793
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(label) { var result = []; for (var guid in this._views_by_guid) { if (this._views_by_guid[guid].label == label) { result.push(this._views_by_guid[guid]); } } return result; }
javascript
function(label) { var result = []; for (var guid in this._views_by_guid) { if (this._views_by_guid[guid].label == label) { result.push(this._views_by_guid[guid]); } } return result; }
[ "function", "(", "label", ")", "{", "var", "result", "=", "[", "]", ";", "for", "(", "var", "guid", "in", "this", ".", "_views_by_guid", ")", "{", "if", "(", "this", ".", "_views_by_guid", "[", "guid", "]", ".", "label", "==", "label", ")", "{", "result", ".", "push", "(", "this", ".", "_views_by_guid", "[", "guid", "]", ")", ";", "}", "}", "return", "result", ";", "}" ]
Filter all created views and find those with `label`. Slow! @param {string} label @returns {Array.<Lava.view.Abstract>}
[ "Filter", "all", "created", "views", "and", "find", "those", "with", "label", ".", "Slow!" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L4158-L4174
46,794
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(element) { // note: target of some events can be the root html tag (for example, mousedown on a scroll bar) var document_ref = window.document, // document > html > body > ... result = []; while (element && element != document_ref) { result.push(element); element = element.parentNode; } // you must not modify the returned array, but you can slice() it if (Lava.schema.DEBUG && Object.freeze) { Object.freeze(result); } return result; }
javascript
function(element) { // note: target of some events can be the root html tag (for example, mousedown on a scroll bar) var document_ref = window.document, // document > html > body > ... result = []; while (element && element != document_ref) { result.push(element); element = element.parentNode; } // you must not modify the returned array, but you can slice() it if (Lava.schema.DEBUG && Object.freeze) { Object.freeze(result); } return result; }
[ "function", "(", "element", ")", "{", "// note: target of some events can be the root html tag (for example, mousedown on a scroll bar)", "var", "document_ref", "=", "window", ".", "document", ",", "// document > html > body > ...", "result", "=", "[", "]", ";", "while", "(", "element", "&&", "element", "!=", "document_ref", ")", "{", "result", ".", "push", "(", "element", ")", ";", "element", "=", "element", ".", "parentNode", ";", "}", "// you must not modify the returned array, but you can slice() it", "if", "(", "Lava", ".", "schema", ".", "DEBUG", "&&", "Object", ".", "freeze", ")", "{", "Object", ".", "freeze", "(", "result", ")", ";", "}", "return", "result", ";", "}" ]
Create an array from element and all it's parents @param {HTMLElement} element @returns {Array.<HTMLElement>}
[ "Create", "an", "array", "from", "element", "and", "all", "it", "s", "parents" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L4255-L4275
46,795
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(event_name, event_object) { var target = event_object.target, view, container, stack_changed_event_name = event_name + '_stack_changed', stack = target ? this._buildElementStack(target) : [], i = 0, count = stack.length; // Warning! You must not modify the `stack` array! this._fire(stack_changed_event_name, stack); for (; i < count; i++) { view = this.getViewByElement(stack[i]); if (view) { container = view.getContainer(); if (container.isElementContainer) { if (container.getEventTargets(event_name)) { this.dispatchEvent(view, event_name, event_object, container.getEventTargets(event_name)); } } } } }
javascript
function(event_name, event_object) { var target = event_object.target, view, container, stack_changed_event_name = event_name + '_stack_changed', stack = target ? this._buildElementStack(target) : [], i = 0, count = stack.length; // Warning! You must not modify the `stack` array! this._fire(stack_changed_event_name, stack); for (; i < count; i++) { view = this.getViewByElement(stack[i]); if (view) { container = view.getContainer(); if (container.isElementContainer) { if (container.getEventTargets(event_name)) { this.dispatchEvent(view, event_name, event_object, container.getEventTargets(event_name)); } } } } }
[ "function", "(", "event_name", ",", "event_object", ")", "{", "var", "target", "=", "event_object", ".", "target", ",", "view", ",", "container", ",", "stack_changed_event_name", "=", "event_name", "+", "'_stack_changed'", ",", "stack", "=", "target", "?", "this", ".", "_buildElementStack", "(", "target", ")", ":", "[", "]", ",", "i", "=", "0", ",", "count", "=", "stack", ".", "length", ";", "// Warning! You must not modify the `stack` array!", "this", ".", "_fire", "(", "stack_changed_event_name", ",", "stack", ")", ";", "for", "(", ";", "i", "<", "count", ";", "i", "++", ")", "{", "view", "=", "this", ".", "getViewByElement", "(", "stack", "[", "i", "]", ")", ";", "if", "(", "view", ")", "{", "container", "=", "view", ".", "getContainer", "(", ")", ";", "if", "(", "container", ".", "isElementContainer", ")", "{", "if", "(", "container", ".", "getEventTargets", "(", "event_name", ")", ")", "{", "this", ".", "dispatchEvent", "(", "view", ",", "event_name", ",", "event_object", ",", "container", ".", "getEventTargets", "(", "event_name", ")", ")", ";", "}", "}", "}", "}", "}" ]
Dispatch DOM events to views @param {string} event_name @param {Object} event_object
[ "Dispatch", "DOM", "events", "to", "views" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L4282-L4307
46,796
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(event_name) { if (Lava.schema.DEBUG && ['mouseenter', 'mouseleave', 'mouseover', 'mouseout'].indexOf(event_name) != -1) Lava.t("The following events: mouseenter, mouseleave, mouseover and mouseout are served by common alias - mouse_events"); if (this._event_usage_counters[event_name]) { this._event_usage_counters[event_name]++; } else { this._event_usage_counters[event_name] = 1; this._initEvent(event_name); } }
javascript
function(event_name) { if (Lava.schema.DEBUG && ['mouseenter', 'mouseleave', 'mouseover', 'mouseout'].indexOf(event_name) != -1) Lava.t("The following events: mouseenter, mouseleave, mouseover and mouseout are served by common alias - mouse_events"); if (this._event_usage_counters[event_name]) { this._event_usage_counters[event_name]++; } else { this._event_usage_counters[event_name] = 1; this._initEvent(event_name); } }
[ "function", "(", "event_name", ")", "{", "if", "(", "Lava", ".", "schema", ".", "DEBUG", "&&", "[", "'mouseenter'", ",", "'mouseleave'", ",", "'mouseover'", ",", "'mouseout'", "]", ".", "indexOf", "(", "event_name", ")", "!=", "-", "1", ")", "Lava", ".", "t", "(", "\"The following events: mouseenter, mouseleave, mouseover and mouseout are served by common alias - mouse_events\"", ")", ";", "if", "(", "this", ".", "_event_usage_counters", "[", "event_name", "]", ")", "{", "this", ".", "_event_usage_counters", "[", "event_name", "]", "++", ";", "}", "else", "{", "this", ".", "_event_usage_counters", "[", "event_name", "]", "=", "1", ";", "this", ".", "_initEvent", "(", "event_name", ")", ";", "}", "}" ]
Register an event consumer and start routing that event @param {string} event_name
[ "Register", "an", "event", "consumer", "and", "start", "routing", "that", "event" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L4313-L4329
46,797
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(event_name) { if (event_name == 'mouse_events') { this._events_listeners['mouseover'] = Lava.Core.addGlobalHandler('mouseover', this.handleMouseMovement, this); this._events_listeners['mouseout'] = Lava.Core.addGlobalHandler('mouseout', this.handleMouseMovement, this); } else { this._events_listeners[event_name] = Lava.Core.addGlobalHandler(event_name, this.onDOMEvent, this); } }
javascript
function(event_name) { if (event_name == 'mouse_events') { this._events_listeners['mouseover'] = Lava.Core.addGlobalHandler('mouseover', this.handleMouseMovement, this); this._events_listeners['mouseout'] = Lava.Core.addGlobalHandler('mouseout', this.handleMouseMovement, this); } else { this._events_listeners[event_name] = Lava.Core.addGlobalHandler(event_name, this.onDOMEvent, this); } }
[ "function", "(", "event_name", ")", "{", "if", "(", "event_name", "==", "'mouse_events'", ")", "{", "this", ".", "_events_listeners", "[", "'mouseover'", "]", "=", "Lava", ".", "Core", ".", "addGlobalHandler", "(", "'mouseover'", ",", "this", ".", "handleMouseMovement", ",", "this", ")", ";", "this", ".", "_events_listeners", "[", "'mouseout'", "]", "=", "Lava", ".", "Core", ".", "addGlobalHandler", "(", "'mouseout'", ",", "this", ".", "handleMouseMovement", ",", "this", ")", ";", "}", "else", "{", "this", ".", "_events_listeners", "[", "event_name", "]", "=", "Lava", ".", "Core", ".", "addGlobalHandler", "(", "event_name", ",", "this", ".", "onDOMEvent", ",", "this", ")", ";", "}", "}" ]
Start listening to an event @param {string} event_name
[ "Start", "listening", "to", "an", "event" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L4335-L4351
46,798
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(event_name) { if (this._event_usage_counters[event_name] == 0) { Lava.logError("ViewManager: trying to release an event with zero usage."); return; } this._event_usage_counters[event_name]--; if (this._event_usage_counters[event_name] == 0) { this._shutdownEvent(event_name); } }
javascript
function(event_name) { if (this._event_usage_counters[event_name] == 0) { Lava.logError("ViewManager: trying to release an event with zero usage."); return; } this._event_usage_counters[event_name]--; if (this._event_usage_counters[event_name] == 0) { this._shutdownEvent(event_name); } }
[ "function", "(", "event_name", ")", "{", "if", "(", "this", ".", "_event_usage_counters", "[", "event_name", "]", "==", "0", ")", "{", "Lava", ".", "logError", "(", "\"ViewManager: trying to release an event with zero usage.\"", ")", ";", "return", ";", "}", "this", ".", "_event_usage_counters", "[", "event_name", "]", "--", ";", "if", "(", "this", ".", "_event_usage_counters", "[", "event_name", "]", "==", "0", ")", "{", "this", ".", "_shutdownEvent", "(", "event_name", ")", ";", "}", "}" ]
Inform that event consumer does not need that event anymore @param {string} event_name
[ "Inform", "that", "event", "consumer", "does", "not", "need", "that", "event", "anymore" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L4357-L4372
46,799
kogarashisan/LiquidLava
lib/packages/core-classes.js
function(event_name) { if (event_name == 'mouse_events') { Lava.Core.removeGlobalHandler(this._events_listeners['mouseover']); this._events_listeners['mouseover'] = null; Lava.Core.removeGlobalHandler(this._events_listeners['mouseout']); this._events_listeners['mouseout'] = null; } else { Lava.Core.removeGlobalHandler(this._events_listeners[event_name]); this._events_listeners[event_name] = null; } }
javascript
function(event_name) { if (event_name == 'mouse_events') { Lava.Core.removeGlobalHandler(this._events_listeners['mouseover']); this._events_listeners['mouseover'] = null; Lava.Core.removeGlobalHandler(this._events_listeners['mouseout']); this._events_listeners['mouseout'] = null; } else { Lava.Core.removeGlobalHandler(this._events_listeners[event_name]); this._events_listeners[event_name] = null; } }
[ "function", "(", "event_name", ")", "{", "if", "(", "event_name", "==", "'mouse_events'", ")", "{", "Lava", ".", "Core", ".", "removeGlobalHandler", "(", "this", ".", "_events_listeners", "[", "'mouseover'", "]", ")", ";", "this", ".", "_events_listeners", "[", "'mouseover'", "]", "=", "null", ";", "Lava", ".", "Core", ".", "removeGlobalHandler", "(", "this", ".", "_events_listeners", "[", "'mouseout'", "]", ")", ";", "this", ".", "_events_listeners", "[", "'mouseout'", "]", "=", "null", ";", "}", "else", "{", "Lava", ".", "Core", ".", "removeGlobalHandler", "(", "this", ".", "_events_listeners", "[", "event_name", "]", ")", ";", "this", ".", "_events_listeners", "[", "event_name", "]", "=", "null", ";", "}", "}" ]
Stop listening to an event @param {string} event_name
[ "Stop", "listening", "to", "an", "event" ]
fb8618821a51fad373106b5cc9247464b0a23cf6
https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/core-classes.js#L4389-L4405