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
44,500
bevacqua/mongotape
drop.js
validate
function validate () { var env = state.env('NODE_ENV'); var uri = state.env('MONGO_URI'); var notTestEnv = env !== 'test'; if (notTestEnv) { throw new Error('NODE_ENV must be set to "test".'); } var notTestDb = word.test(uri) === false; if (notTestDb) { throw new Error('MONGO_URI must contain "test" word.'); } }
javascript
function validate () { var env = state.env('NODE_ENV'); var uri = state.env('MONGO_URI'); var notTestEnv = env !== 'test'; if (notTestEnv) { throw new Error('NODE_ENV must be set to "test".'); } var notTestDb = word.test(uri) === false; if (notTestDb) { throw new Error('MONGO_URI must contain "test" word.'); } }
[ "function", "validate", "(", ")", "{", "var", "env", "=", "state", ".", "env", "(", "'NODE_ENV'", ")", ";", "var", "uri", "=", "state", ".", "env", "(", "'MONGO_URI'", ")", ";", "var", "notTestEnv", "=", "env", "!==", "'test'", ";", "if", "(", "notTestEnv", ")", "{", "throw", "new", "Error", "(", "'NODE_ENV must be set to \"test\".'", ")", ";", "}", "var", "notTestDb", "=", "word", ".", "test", "(", "uri", ")", "===", "false", ";", "if", "(", "notTestDb", ")", "{", "throw", "new", "Error", "(", "'MONGO_URI must contain \"test\" word.'", ")", ";", "}", "}" ]
being able to drop the database is kind of a big deal disallow outside of 'test' environment, and also outside of 'test' database
[ "being", "able", "to", "drop", "the", "database", "is", "kind", "of", "a", "big", "deal", "disallow", "outside", "of", "test", "environment", "and", "also", "outside", "of", "test", "database" ]
d7124a4bde55c64d5ebfda1526a6d6fbc82c27cc
https://github.com/bevacqua/mongotape/blob/d7124a4bde55c64d5ebfda1526a6d6fbc82c27cc/drop.js#L8-L19
44,501
sematext/spm-agent
lib/index.js
shipMetrics
function shipMetrics (metric) { try { this.emit('metric', metric) this.spmSender.collectMetric(metric) } catch (ex) { logger.error('Error in shipMetrics' + ex.stack) } }
javascript
function shipMetrics (metric) { try { this.emit('metric', metric) this.spmSender.collectMetric(metric) } catch (ex) { logger.error('Error in shipMetrics' + ex.stack) } }
[ "function", "shipMetrics", "(", "metric", ")", "{", "try", "{", "this", ".", "emit", "(", "'metric'", ",", "metric", ")", "this", ".", "spmSender", ".", "collectMetric", "(", "metric", ")", "}", "catch", "(", "ex", ")", "{", "logger", ".", "error", "(", "'Error in shipMetrics'", "+", "ex", ".", "stack", ")", "}", "}" ]
Event listener method for metrics, pushing metrics to spmsender module @param {Object} metric Object
[ "Event", "listener", "method", "for", "metrics", "pushing", "metrics", "to", "spmsender", "module" ]
7b98be0cfc41fb7bf7f7c605e6602148570269a3
https://github.com/sematext/spm-agent/blob/7b98be0cfc41fb7bf7f7c605e6602148570269a3/lib/index.js#L37-L44
44,502
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(view){ var viewCid = view.cid; // delete model index if (view.model){ delete this._indexByModel[view.model.cid]; } // delete custom index _.any(this._indexByCustom, function(cid, key) { if (cid === viewCid) { delete this._indexByCustom[key]; return true; } }, this); // remove the view from the container delete this._views[viewCid]; // update the length this._updateLength(); }
javascript
function(view){ var viewCid = view.cid; // delete model index if (view.model){ delete this._indexByModel[view.model.cid]; } // delete custom index _.any(this._indexByCustom, function(cid, key) { if (cid === viewCid) { delete this._indexByCustom[key]; return true; } }, this); // remove the view from the container delete this._views[viewCid]; // update the length this._updateLength(); }
[ "function", "(", "view", ")", "{", "var", "viewCid", "=", "view", ".", "cid", ";", "// delete model index", "if", "(", "view", ".", "model", ")", "{", "delete", "this", ".", "_indexByModel", "[", "view", ".", "model", ".", "cid", "]", ";", "}", "// delete custom index", "_", ".", "any", "(", "this", ".", "_indexByCustom", ",", "function", "(", "cid", ",", "key", ")", "{", "if", "(", "cid", "===", "viewCid", ")", "{", "delete", "this", ".", "_indexByCustom", "[", "key", "]", ";", "return", "true", ";", "}", "}", ",", "this", ")", ";", "// remove the view from the container", "delete", "this", ".", "_views", "[", "viewCid", "]", ";", "// update the length", "this", ".", "_updateLength", "(", ")", ";", "}" ]
Remove a view
[ "Remove", "a", "view" ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L109-L130
44,503
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(method, args){ _.each(this._views, function(view){ if (_.isFunction(view[method])){ view[method].apply(view, args || []); } }); }
javascript
function(method, args){ _.each(this._views, function(view){ if (_.isFunction(view[method])){ view[method].apply(view, args || []); } }); }
[ "function", "(", "method", ",", "args", ")", "{", "_", ".", "each", "(", "this", ".", "_views", ",", "function", "(", "view", ")", "{", "if", "(", "_", ".", "isFunction", "(", "view", "[", "method", "]", ")", ")", "{", "view", "[", "method", "]", ".", "apply", "(", "view", ",", "args", "||", "[", "]", ")", ";", "}", "}", ")", ";", "}" ]
Apply a method on every view in the container, passing parameters to the call method one at a time, like `function.apply`.
[ "Apply", "a", "method", "on", "every", "view", "in", "the", "container", "passing", "parameters", "to", "the", "call", "method", "one", "at", "a", "time", "like", "function", ".", "apply", "." ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L142-L148
44,504
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(handlers){ _.each(handlers, function(handler, name){ var context = null; if (_.isObject(handler) && !_.isFunction(handler)){ context = handler.context; handler = handler.callback; } this.setHandler(name, handler, context); }, this); }
javascript
function(handlers){ _.each(handlers, function(handler, name){ var context = null; if (_.isObject(handler) && !_.isFunction(handler)){ context = handler.context; handler = handler.callback; } this.setHandler(name, handler, context); }, this); }
[ "function", "(", "handlers", ")", "{", "_", ".", "each", "(", "handlers", ",", "function", "(", "handler", ",", "name", ")", "{", "var", "context", "=", "null", ";", "if", "(", "_", ".", "isObject", "(", "handler", ")", "&&", "!", "_", ".", "isFunction", "(", "handler", ")", ")", "{", "context", "=", "handler", ".", "context", ";", "handler", "=", "handler", ".", "callback", ";", "}", "this", ".", "setHandler", "(", "name", ",", "handler", ",", "context", ")", ";", "}", ",", "this", ")", ";", "}" ]
Add multiple handlers using an object literal configuration
[ "Add", "multiple", "handlers", "using", "an", "object", "literal", "configuration" ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L219-L230
44,505
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(name, handler, context){ var config = { callback: handler, context: context }; this._wreqrHandlers[name] = config; this.trigger("handler:add", name, handler, context); }
javascript
function(name, handler, context){ var config = { callback: handler, context: context }; this._wreqrHandlers[name] = config; this.trigger("handler:add", name, handler, context); }
[ "function", "(", "name", ",", "handler", ",", "context", ")", "{", "var", "config", "=", "{", "callback", ":", "handler", ",", "context", ":", "context", "}", ";", "this", ".", "_wreqrHandlers", "[", "name", "]", "=", "config", ";", "this", ".", "trigger", "(", "\"handler:add\"", ",", "name", ",", "handler", ",", "context", ")", ";", "}" ]
Add a handler for the given name, with an optional context to run the handler within
[ "Add", "a", "handler", "for", "the", "given", "name", "with", "an", "optional", "context", "to", "run", "the", "handler", "within" ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L234-L243
44,506
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(name){ var config = this._wreqrHandlers[name]; if (!config){ throw new Error("Handler not found for '" + name + "'"); } return function(){ var args = Array.prototype.slice.apply(arguments); return config.callback.apply(config.context, args); }; }
javascript
function(name){ var config = this._wreqrHandlers[name]; if (!config){ throw new Error("Handler not found for '" + name + "'"); } return function(){ var args = Array.prototype.slice.apply(arguments); return config.callback.apply(config.context, args); }; }
[ "function", "(", "name", ")", "{", "var", "config", "=", "this", ".", "_wreqrHandlers", "[", "name", "]", ";", "if", "(", "!", "config", ")", "{", "throw", "new", "Error", "(", "\"Handler not found for '\"", "+", "name", "+", "\"'\"", ")", ";", "}", "return", "function", "(", ")", "{", "var", "args", "=", "Array", ".", "prototype", ".", "slice", ".", "apply", "(", "arguments", ")", ";", "return", "config", ".", "callback", ".", "apply", "(", "config", ".", "context", ",", "args", ")", ";", "}", ";", "}" ]
Get the currently registered handler for the specified name. Throws an exception if no handler is found.
[ "Get", "the", "currently", "registered", "handler", "for", "the", "specified", "name", ".", "Throws", "an", "exception", "if", "no", "handler", "is", "found", "." ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L253-L264
44,507
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(commandName){ var commands = this._commands[commandName]; // we don't have it, so add it if (!commands){ // build the configuration commands = { command: commandName, instances: [] }; // store it this._commands[commandName] = commands; } return commands; }
javascript
function(commandName){ var commands = this._commands[commandName]; // we don't have it, so add it if (!commands){ // build the configuration commands = { command: commandName, instances: [] }; // store it this._commands[commandName] = commands; } return commands; }
[ "function", "(", "commandName", ")", "{", "var", "commands", "=", "this", ".", "_commands", "[", "commandName", "]", ";", "// we don't have it, so add it", "if", "(", "!", "commands", ")", "{", "// build the configuration", "commands", "=", "{", "command", ":", "commandName", ",", "instances", ":", "[", "]", "}", ";", "// store it", "this", ".", "_commands", "[", "commandName", "]", "=", "commands", ";", "}", "return", "commands", ";", "}" ]
Get an object literal by command name, that contains the `commandName` and the `instances` of all commands represented as an array of arguments to process
[ "Get", "an", "object", "literal", "by", "command", "name", "that", "contains", "the", "commandName", "and", "the", "instances", "of", "all", "commands", "represented", "as", "an", "array", "of", "arguments", "to", "process" ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L303-L320
44,508
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(name, args){ name = arguments[0]; args = Array.prototype.slice.call(arguments, 1); if (this.hasHandler(name)){ this.getHandler(name).apply(this, args); } else { this.storage.addCommand(name, args); } }
javascript
function(name, args){ name = arguments[0]; args = Array.prototype.slice.call(arguments, 1); if (this.hasHandler(name)){ this.getHandler(name).apply(this, args); } else { this.storage.addCommand(name, args); } }
[ "function", "(", "name", ",", "args", ")", "{", "name", "=", "arguments", "[", "0", "]", ";", "args", "=", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ",", "1", ")", ";", "if", "(", "this", ".", "hasHandler", "(", "name", ")", ")", "{", "this", ".", "getHandler", "(", "name", ")", ".", "apply", "(", "this", ",", "args", ")", ";", "}", "else", "{", "this", ".", "storage", ".", "addCommand", "(", "name", ",", "args", ")", ";", "}", "}" ]
Execute a named command with the supplied args
[ "Execute", "a", "named", "command", "with", "the", "supplied", "args" ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L362-L372
44,509
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(name, handler, context){ var command = this.storage.getCommands(name); // loop through and execute all the stored command instances _.each(command.instances, function(args){ handler.apply(context, args); }); this.storage.clearCommands(name); }
javascript
function(name, handler, context){ var command = this.storage.getCommands(name); // loop through and execute all the stored command instances _.each(command.instances, function(args){ handler.apply(context, args); }); this.storage.clearCommands(name); }
[ "function", "(", "name", ",", "handler", ",", "context", ")", "{", "var", "command", "=", "this", ".", "storage", ".", "getCommands", "(", "name", ")", ";", "// loop through and execute all the stored command instances", "_", ".", "each", "(", "command", ".", "instances", ",", "function", "(", "args", ")", "{", "handler", ".", "apply", "(", "context", ",", "args", ")", ";", "}", ")", ";", "this", ".", "storage", ".", "clearCommands", "(", "name", ")", ";", "}" ]
Internal method to handle bulk execution of stored commands
[ "Internal", "method", "to", "handle", "bulk", "execution", "of", "stored", "commands" ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L375-L384
44,510
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(options){ var storage; var StorageType = options.storageType || this.storageType; if (_.isFunction(StorageType)){ storage = new StorageType(); } else { storage = StorageType; } this.storage = storage; }
javascript
function(options){ var storage; var StorageType = options.storageType || this.storageType; if (_.isFunction(StorageType)){ storage = new StorageType(); } else { storage = StorageType; } this.storage = storage; }
[ "function", "(", "options", ")", "{", "var", "storage", ";", "var", "StorageType", "=", "options", ".", "storageType", "||", "this", ".", "storageType", ";", "if", "(", "_", ".", "isFunction", "(", "StorageType", ")", ")", "{", "storage", "=", "new", "StorageType", "(", ")", ";", "}", "else", "{", "storage", "=", "StorageType", ";", "}", "this", ".", "storage", "=", "storage", ";", "}" ]
Internal method to initialize storage either from the type's `storageType` or the instance `options.storageType`.
[ "Internal", "method", "to", "initialize", "storage", "either", "from", "the", "type", "s", "storageType", "or", "the", "instance", "options", ".", "storageType", "." ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L388-L399
44,511
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(event) { // get the method name from the event name var methodName = 'on' + event.replace(splitter, getEventName); var method = this[methodName]; // trigger the event, if a trigger method exists if(_.isFunction(this.trigger)) { this.trigger.apply(this, arguments); } // call the onMethodName if it exists if (_.isFunction(method)) { // pass all arguments, except the event name return method.apply(this, _.tail(arguments)); } }
javascript
function(event) { // get the method name from the event name var methodName = 'on' + event.replace(splitter, getEventName); var method = this[methodName]; // trigger the event, if a trigger method exists if(_.isFunction(this.trigger)) { this.trigger.apply(this, arguments); } // call the onMethodName if it exists if (_.isFunction(method)) { // pass all arguments, except the event name return method.apply(this, _.tail(arguments)); } }
[ "function", "(", "event", ")", "{", "// get the method name from the event name", "var", "methodName", "=", "'on'", "+", "event", ".", "replace", "(", "splitter", ",", "getEventName", ")", ";", "var", "method", "=", "this", "[", "methodName", "]", ";", "// trigger the event, if a trigger method exists", "if", "(", "_", ".", "isFunction", "(", "this", ".", "trigger", ")", ")", "{", "this", ".", "trigger", ".", "apply", "(", "this", ",", "arguments", ")", ";", "}", "// call the onMethodName if it exists", "if", "(", "_", ".", "isFunction", "(", "method", ")", ")", "{", "// pass all arguments, except the event name", "return", "method", ".", "apply", "(", "this", ",", "_", ".", "tail", "(", "arguments", ")", ")", ";", "}", "}" ]
actual triggerMethod name
[ "actual", "triggerMethod", "name" ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L513-L528
44,512
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
iterateEvents
function iterateEvents(target, entity, bindings, functionCallback, stringCallback){ if (!entity || !bindings) { return; } // allow the bindings to be a function if (_.isFunction(bindings)){ bindings = bindings.call(target); } // iterate the bindings and bind them _.each(bindings, function(methods, evt){ // allow for a function as the handler, // or a list of event names as a string if (_.isFunction(methods)){ functionCallback(target, entity, evt, methods); } else { stringCallback(target, entity, evt, methods); } }); }
javascript
function iterateEvents(target, entity, bindings, functionCallback, stringCallback){ if (!entity || !bindings) { return; } // allow the bindings to be a function if (_.isFunction(bindings)){ bindings = bindings.call(target); } // iterate the bindings and bind them _.each(bindings, function(methods, evt){ // allow for a function as the handler, // or a list of event names as a string if (_.isFunction(methods)){ functionCallback(target, entity, evt, methods); } else { stringCallback(target, entity, evt, methods); } }); }
[ "function", "iterateEvents", "(", "target", ",", "entity", ",", "bindings", ",", "functionCallback", ",", "stringCallback", ")", "{", "if", "(", "!", "entity", "||", "!", "bindings", ")", "{", "return", ";", "}", "// allow the bindings to be a function", "if", "(", "_", ".", "isFunction", "(", "bindings", ")", ")", "{", "bindings", "=", "bindings", ".", "call", "(", "target", ")", ";", "}", "// iterate the bindings and bind them", "_", ".", "each", "(", "bindings", ",", "function", "(", "methods", ",", "evt", ")", "{", "// allow for a function as the handler, ", "// or a list of event names as a string", "if", "(", "_", ".", "isFunction", "(", "methods", ")", ")", "{", "functionCallback", "(", "target", ",", "entity", ",", "evt", ",", "methods", ")", ";", "}", "else", "{", "stringCallback", "(", "target", ",", "entity", ",", "evt", ",", "methods", ")", ";", "}", "}", ")", ";", "}" ]
generic looping function
[ "generic", "looping", "function" ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L634-L654
44,513
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(callback, contextOverride){ this._callbacks.push({cb: callback, ctx: contextOverride}); this._deferred.done(function(context, options){ if (contextOverride){ context = contextOverride; } callback.call(context, options); }); }
javascript
function(callback, contextOverride){ this._callbacks.push({cb: callback, ctx: contextOverride}); this._deferred.done(function(context, options){ if (contextOverride){ context = contextOverride; } callback.call(context, options); }); }
[ "function", "(", "callback", ",", "contextOverride", ")", "{", "this", ".", "_callbacks", ".", "push", "(", "{", "cb", ":", "callback", ",", "ctx", ":", "contextOverride", "}", ")", ";", "this", ".", "_deferred", ".", "done", "(", "function", "(", "context", ",", "options", ")", "{", "if", "(", "contextOverride", ")", "{", "context", "=", "contextOverride", ";", "}", "callback", ".", "call", "(", "context", ",", "options", ")", ";", "}", ")", ";", "}" ]
Add a callback to be executed. Callbacks added here are guaranteed to execute, even if they are added after the `run` method is called.
[ "Add", "a", "callback", "to", "be", "executed", ".", "Callbacks", "added", "here", "are", "guaranteed", "to", "execute", "even", "if", "they", "are", "added", "after", "the", "run", "method", "is", "called", "." ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L684-L691
44,514
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(){ var callbacks = this._callbacks; this._deferred = Marionette.$.Deferred(); this._callbacks = []; _.each(callbacks, function(cb){ this.add(cb.cb, cb.ctx); }, this); }
javascript
function(){ var callbacks = this._callbacks; this._deferred = Marionette.$.Deferred(); this._callbacks = []; _.each(callbacks, function(cb){ this.add(cb.cb, cb.ctx); }, this); }
[ "function", "(", ")", "{", "var", "callbacks", "=", "this", ".", "_callbacks", ";", "this", ".", "_deferred", "=", "Marionette", ".", "$", ".", "Deferred", "(", ")", ";", "this", ".", "_callbacks", "=", "[", "]", ";", "_", ".", "each", "(", "callbacks", ",", "function", "(", "cb", ")", "{", "this", ".", "add", "(", "cb", ".", "cb", ",", "cb", ".", "ctx", ")", ";", "}", ",", "this", ")", ";", "}" ]
Resets the list of callbacks to be run, allowing the same list to be run multiple times - whenever the `run` method is called.
[ "Resets", "the", "list", "of", "callbacks", "to", "be", "run", "allowing", "the", "same", "list", "to", "be", "run", "multiple", "times", "-", "whenever", "the", "run", "method", "is", "called", "." ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L702-L710
44,515
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(view){ this.ensureEl(); var isViewClosed = view.isClosed || _.isUndefined(view.$el); var isDifferentView = view !== this.currentView; if (isDifferentView) { this.close(); } view.render(); if (isDifferentView || isViewClosed) { this.open(view); } this.currentView = view; Marionette.triggerMethod.call(this, "show", view); Marionette.triggerMethod.call(view, "show"); }
javascript
function(view){ this.ensureEl(); var isViewClosed = view.isClosed || _.isUndefined(view.$el); var isDifferentView = view !== this.currentView; if (isDifferentView) { this.close(); } view.render(); if (isDifferentView || isViewClosed) { this.open(view); } this.currentView = view; Marionette.triggerMethod.call(this, "show", view); Marionette.triggerMethod.call(view, "show"); }
[ "function", "(", "view", ")", "{", "this", ".", "ensureEl", "(", ")", ";", "var", "isViewClosed", "=", "view", ".", "isClosed", "||", "_", ".", "isUndefined", "(", "view", ".", "$el", ")", ";", "var", "isDifferentView", "=", "view", "!==", "this", ".", "currentView", ";", "if", "(", "isDifferentView", ")", "{", "this", ".", "close", "(", ")", ";", "}", "view", ".", "render", "(", ")", ";", "if", "(", "isDifferentView", "||", "isViewClosed", ")", "{", "this", ".", "open", "(", "view", ")", ";", "}", "this", ".", "currentView", "=", "view", ";", "Marionette", ".", "triggerMethod", ".", "call", "(", "this", ",", "\"show\"", ",", "view", ")", ";", "Marionette", ".", "triggerMethod", ".", "call", "(", "view", ",", "\"show\"", ")", ";", "}" ]
Displays a backbone view instance inside of the region. Handles calling the `render` method for you. Reads content directly from the `el` attribute. Also calls an optional `onShow` and `close` method on your view, just after showing or just before closing the view, respectively.
[ "Displays", "a", "backbone", "view", "instance", "inside", "of", "the", "region", ".", "Handles", "calling", "the", "render", "method", "for", "you", ".", "Reads", "content", "directly", "from", "the", "el", "attribute", ".", "Also", "calls", "an", "optional", "onShow", "and", "close", "method", "on", "your", "view", "just", "after", "showing", "or", "just", "before", "closing", "the", "view", "respectively", "." ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L860-L882
44,516
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(){ var view = this.currentView; if (!view || view.isClosed){ return; } // call 'close' or 'remove', depending on which is found if (view.close) { view.close(); } else if (view.remove) { view.remove(); } Marionette.triggerMethod.call(this, "close"); delete this.currentView; }
javascript
function(){ var view = this.currentView; if (!view || view.isClosed){ return; } // call 'close' or 'remove', depending on which is found if (view.close) { view.close(); } else if (view.remove) { view.remove(); } Marionette.triggerMethod.call(this, "close"); delete this.currentView; }
[ "function", "(", ")", "{", "var", "view", "=", "this", ".", "currentView", ";", "if", "(", "!", "view", "||", "view", ".", "isClosed", ")", "{", "return", ";", "}", "// call 'close' or 'remove', depending on which is found", "if", "(", "view", ".", "close", ")", "{", "view", ".", "close", "(", ")", ";", "}", "else", "if", "(", "view", ".", "remove", ")", "{", "view", ".", "remove", "(", ")", ";", "}", "Marionette", ".", "triggerMethod", ".", "call", "(", "this", ",", "\"close\"", ")", ";", "delete", "this", ".", "currentView", ";", "}" ]
Close the current view, if there is one. If there is no current view, it does nothing and returns immediately.
[ "Close", "the", "current", "view", "if", "there", "is", "one", ".", "If", "there", "is", "no", "current", "view", "it", "does", "nothing", "and", "returns", "immediately", "." ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L904-L915
44,517
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(regionDefinitions, defaults){ var regions = {}; _.each(regionDefinitions, function(definition, name){ if (typeof definition === "string"){ definition = { selector: definition }; } if (definition.selector){ definition = _.defaults({}, definition, defaults); } var region = this.addRegion(name, definition); regions[name] = region; }, this); return regions; }
javascript
function(regionDefinitions, defaults){ var regions = {}; _.each(regionDefinitions, function(definition, name){ if (typeof definition === "string"){ definition = { selector: definition }; } if (definition.selector){ definition = _.defaults({}, definition, defaults); } var region = this.addRegion(name, definition); regions[name] = region; }, this); return regions; }
[ "function", "(", "regionDefinitions", ",", "defaults", ")", "{", "var", "regions", "=", "{", "}", ";", "_", ".", "each", "(", "regionDefinitions", ",", "function", "(", "definition", ",", "name", ")", "{", "if", "(", "typeof", "definition", "===", "\"string\"", ")", "{", "definition", "=", "{", "selector", ":", "definition", "}", ";", "}", "if", "(", "definition", ".", "selector", ")", "{", "definition", "=", "_", ".", "defaults", "(", "{", "}", ",", "definition", ",", "defaults", ")", ";", "}", "var", "region", "=", "this", ".", "addRegion", "(", "name", ",", "definition", ")", ";", "regions", "[", "name", "]", "=", "region", ";", "}", ",", "this", ")", ";", "return", "regions", ";", "}" ]
Add multiple regions using an object literal, where each key becomes the region name, and each value is the region definition.
[ "Add", "multiple", "regions", "using", "an", "object", "literal", "where", "each", "key", "becomes", "the", "region", "name", "and", "each", "value", "is", "the", "region", "definition", "." ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L953-L970
44,518
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(name, definition){ var region; var isObject = _.isObject(definition); var isString = _.isString(definition); var hasSelector = !!definition.selector; if (isString || (isObject && hasSelector)){ region = Marionette.Region.buildRegion(definition, Marionette.Region); } else if (_.isFunction(definition)){ region = Marionette.Region.buildRegion(definition, Marionette.Region); } else { region = definition; } this._store(name, region); this.triggerMethod("region:add", name, region); return region; }
javascript
function(name, definition){ var region; var isObject = _.isObject(definition); var isString = _.isString(definition); var hasSelector = !!definition.selector; if (isString || (isObject && hasSelector)){ region = Marionette.Region.buildRegion(definition, Marionette.Region); } else if (_.isFunction(definition)){ region = Marionette.Region.buildRegion(definition, Marionette.Region); } else { region = definition; } this._store(name, region); this.triggerMethod("region:add", name, region); return region; }
[ "function", "(", "name", ",", "definition", ")", "{", "var", "region", ";", "var", "isObject", "=", "_", ".", "isObject", "(", "definition", ")", ";", "var", "isString", "=", "_", ".", "isString", "(", "definition", ")", ";", "var", "hasSelector", "=", "!", "!", "definition", ".", "selector", ";", "if", "(", "isString", "||", "(", "isObject", "&&", "hasSelector", ")", ")", "{", "region", "=", "Marionette", ".", "Region", ".", "buildRegion", "(", "definition", ",", "Marionette", ".", "Region", ")", ";", "}", "else", "if", "(", "_", ".", "isFunction", "(", "definition", ")", ")", "{", "region", "=", "Marionette", ".", "Region", ".", "buildRegion", "(", "definition", ",", "Marionette", ".", "Region", ")", ";", "}", "else", "{", "region", "=", "definition", ";", "}", "this", ".", "_store", "(", "name", ",", "region", ")", ";", "this", ".", "triggerMethod", "(", "\"region:add\"", ",", "name", ",", "region", ")", ";", "return", "region", ";", "}" ]
Add an individual region to the region manager, and return the region instance
[ "Add", "an", "individual", "region", "to", "the", "region", "manager", "and", "return", "the", "region", "instance" ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L974-L992
44,519
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(){ this.removeRegions(); var args = Array.prototype.slice.call(arguments); Marionette.Controller.prototype.close.apply(this, args); }
javascript
function(){ this.removeRegions(); var args = Array.prototype.slice.call(arguments); Marionette.Controller.prototype.close.apply(this, args); }
[ "function", "(", ")", "{", "this", ".", "removeRegions", "(", ")", ";", "var", "args", "=", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ")", ";", "Marionette", ".", "Controller", ".", "prototype", ".", "close", ".", "apply", "(", "this", ",", "args", ")", ";", "}" ]
Close all regions and shut down the region manager entirely
[ "Close", "all", "regions", "and", "shut", "down", "the", "region", "manager", "entirely" ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1023-L1027
44,520
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(name, region){ region.close(); delete this._regions[name]; this._setLength(); this.triggerMethod("region:remove", name, region); }
javascript
function(name, region){ region.close(); delete this._regions[name]; this._setLength(); this.triggerMethod("region:remove", name, region); }
[ "function", "(", "name", ",", "region", ")", "{", "region", ".", "close", "(", ")", ";", "delete", "this", ".", "_regions", "[", "name", "]", ";", "this", ".", "_setLength", "(", ")", ";", "this", ".", "triggerMethod", "(", "\"region:remove\"", ",", "name", ",", "region", ")", ";", "}" ]
internal method to remove a region
[ "internal", "method", "to", "remove", "a", "region" ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1036-L1041
44,521
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(template, data){ if (!template) { var error = new Error("Cannot render the template since it's false, null or undefined."); error.name = "TemplateNotFoundError"; throw error; } var templateFunc; if (typeof template === "function"){ templateFunc = template; } else { templateFunc = Marionette.TemplateCache.get(template); } return templateFunc(data); }
javascript
function(template, data){ if (!template) { var error = new Error("Cannot render the template since it's false, null or undefined."); error.name = "TemplateNotFoundError"; throw error; } var templateFunc; if (typeof template === "function"){ templateFunc = template; } else { templateFunc = Marionette.TemplateCache.get(template); } return templateFunc(data); }
[ "function", "(", "template", ",", "data", ")", "{", "if", "(", "!", "template", ")", "{", "var", "error", "=", "new", "Error", "(", "\"Cannot render the template since it's false, null or undefined.\"", ")", ";", "error", ".", "name", "=", "\"TemplateNotFoundError\"", ";", "throw", "error", ";", "}", "var", "templateFunc", ";", "if", "(", "typeof", "template", "===", "\"function\"", ")", "{", "templateFunc", "=", "template", ";", "}", "else", "{", "templateFunc", "=", "Marionette", ".", "TemplateCache", ".", "get", "(", "template", ")", ";", "}", "return", "templateFunc", "(", "data", ")", ";", "}" ]
Render a template with data. The `template` parameter is passed to the `TemplateCache` object to retrieve the template function. Override this method to provide your own custom rendering and template handling for all of Marionette.
[ "Render", "a", "template", "with", "data", ".", "The", "template", "parameter", "is", "passed", "to", "the", "TemplateCache", "object", "to", "retrieve", "the", "template", "function", ".", "Override", "this", "method", "to", "provide", "your", "own", "custom", "rendering", "and", "template", "handling", "for", "all", "of", "Marionette", "." ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1178-L1194
44,522
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(target){ target = target || {}; var templateHelpers = Marionette.getOption(this, "templateHelpers"); if (_.isFunction(templateHelpers)){ templateHelpers = templateHelpers.call(this); } return _.extend(target, templateHelpers); }
javascript
function(target){ target = target || {}; var templateHelpers = Marionette.getOption(this, "templateHelpers"); if (_.isFunction(templateHelpers)){ templateHelpers = templateHelpers.call(this); } return _.extend(target, templateHelpers); }
[ "function", "(", "target", ")", "{", "target", "=", "target", "||", "{", "}", ";", "var", "templateHelpers", "=", "Marionette", ".", "getOption", "(", "this", ",", "\"templateHelpers\"", ")", ";", "if", "(", "_", ".", "isFunction", "(", "templateHelpers", ")", ")", "{", "templateHelpers", "=", "templateHelpers", ".", "call", "(", "this", ")", ";", "}", "return", "_", ".", "extend", "(", "target", ",", "templateHelpers", ")", ";", "}" ]
Mix in template helper methods. Looks for a `templateHelpers` attribute, which can either be an object literal, or a function that returns an object literal. All methods and attributes from this object are copies to the object passed in.
[ "Mix", "in", "template", "helper", "methods", ".", "Looks", "for", "a", "templateHelpers", "attribute", "which", "can", "either", "be", "an", "object", "literal", "or", "a", "function", "that", "returns", "an", "object", "literal", ".", "All", "methods", "and", "attributes", "from", "this", "object", "are", "copies", "to", "the", "object", "passed", "in", "." ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1232-L1239
44,523
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(events){ this._delegateDOMEvents(events); Marionette.bindEntityEvents(this, this.model, Marionette.getOption(this, "modelEvents")); Marionette.bindEntityEvents(this, this.collection, Marionette.getOption(this, "collectionEvents")); }
javascript
function(events){ this._delegateDOMEvents(events); Marionette.bindEntityEvents(this, this.model, Marionette.getOption(this, "modelEvents")); Marionette.bindEntityEvents(this, this.collection, Marionette.getOption(this, "collectionEvents")); }
[ "function", "(", "events", ")", "{", "this", ".", "_delegateDOMEvents", "(", "events", ")", ";", "Marionette", ".", "bindEntityEvents", "(", "this", ",", "this", ".", "model", ",", "Marionette", ".", "getOption", "(", "this", ",", "\"modelEvents\"", ")", ")", ";", "Marionette", ".", "bindEntityEvents", "(", "this", ",", "this", ".", "collection", ",", "Marionette", ".", "getOption", "(", "this", ",", "\"collectionEvents\"", ")", ")", ";", "}" ]
Overriding Backbone.View's delegateEvents to handle the `triggers`, `modelEvents`, and `collectionEvents` configuration
[ "Overriding", "Backbone", ".", "View", "s", "delegateEvents", "to", "handle", "the", "triggers", "modelEvents", "and", "collectionEvents", "configuration" ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1280-L1284
44,524
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(events){ events = events || this.events; if (_.isFunction(events)){ events = events.call(this); } var combinedEvents = {}; var triggers = this.configureTriggers(); _.extend(combinedEvents, events, triggers); Backbone.View.prototype.delegateEvents.call(this, combinedEvents); }
javascript
function(events){ events = events || this.events; if (_.isFunction(events)){ events = events.call(this); } var combinedEvents = {}; var triggers = this.configureTriggers(); _.extend(combinedEvents, events, triggers); Backbone.View.prototype.delegateEvents.call(this, combinedEvents); }
[ "function", "(", "events", ")", "{", "events", "=", "events", "||", "this", ".", "events", ";", "if", "(", "_", ".", "isFunction", "(", "events", ")", ")", "{", "events", "=", "events", ".", "call", "(", "this", ")", ";", "}", "var", "combinedEvents", "=", "{", "}", ";", "var", "triggers", "=", "this", ".", "configureTriggers", "(", ")", ";", "_", ".", "extend", "(", "combinedEvents", ",", "events", ",", "triggers", ")", ";", "Backbone", ".", "View", ".", "prototype", ".", "delegateEvents", ".", "call", "(", "this", ",", "combinedEvents", ")", ";", "}" ]
internal method to delegate DOM events and triggers
[ "internal", "method", "to", "delegate", "DOM", "events", "and", "triggers" ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1287-L1296
44,525
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(){ var args = Array.prototype.slice.call(arguments); Backbone.View.prototype.undelegateEvents.apply(this, args); Marionette.unbindEntityEvents(this, this.model, Marionette.getOption(this, "modelEvents")); Marionette.unbindEntityEvents(this, this.collection, Marionette.getOption(this, "collectionEvents")); }
javascript
function(){ var args = Array.prototype.slice.call(arguments); Backbone.View.prototype.undelegateEvents.apply(this, args); Marionette.unbindEntityEvents(this, this.model, Marionette.getOption(this, "modelEvents")); Marionette.unbindEntityEvents(this, this.collection, Marionette.getOption(this, "collectionEvents")); }
[ "function", "(", ")", "{", "var", "args", "=", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ")", ";", "Backbone", ".", "View", ".", "prototype", ".", "undelegateEvents", ".", "apply", "(", "this", ",", "args", ")", ";", "Marionette", ".", "unbindEntityEvents", "(", "this", ",", "this", ".", "model", ",", "Marionette", ".", "getOption", "(", "this", ",", "\"modelEvents\"", ")", ")", ";", "Marionette", ".", "unbindEntityEvents", "(", "this", ",", "this", ".", "collection", ",", "Marionette", ".", "getOption", "(", "this", ",", "\"collectionEvents\"", ")", ")", ";", "}" ]
Overriding Backbone.View's undelegateEvents to handle unbinding the `triggers`, `modelEvents`, and `collectionEvents` config
[ "Overriding", "Backbone", ".", "View", "s", "undelegateEvents", "to", "handle", "unbinding", "the", "triggers", "modelEvents", "and", "collectionEvents", "config" ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1300-L1306
44,526
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(){ if (this.isClosed) { return; } // allow the close to be stopped by returning `false` // from the `onBeforeClose` method var shouldClose = this.triggerMethod("before:close"); if (shouldClose === false){ return; } // mark as closed before doing the actual close, to // prevent infinite loops within "close" event handlers // that are trying to close other views this.isClosed = true; this.triggerMethod("close"); // unbind UI elements this.unbindUIElements(); // remove the view from the DOM this.remove(); }
javascript
function(){ if (this.isClosed) { return; } // allow the close to be stopped by returning `false` // from the `onBeforeClose` method var shouldClose = this.triggerMethod("before:close"); if (shouldClose === false){ return; } // mark as closed before doing the actual close, to // prevent infinite loops within "close" event handlers // that are trying to close other views this.isClosed = true; this.triggerMethod("close"); // unbind UI elements this.unbindUIElements(); // remove the view from the DOM this.remove(); }
[ "function", "(", ")", "{", "if", "(", "this", ".", "isClosed", ")", "{", "return", ";", "}", "// allow the close to be stopped by returning `false`", "// from the `onBeforeClose` method", "var", "shouldClose", "=", "this", ".", "triggerMethod", "(", "\"before:close\"", ")", ";", "if", "(", "shouldClose", "===", "false", ")", "{", "return", ";", "}", "// mark as closed before doing the actual close, to", "// prevent infinite loops within \"close\" event handlers", "// that are trying to close other views", "this", ".", "isClosed", "=", "true", ";", "this", ".", "triggerMethod", "(", "\"close\"", ")", ";", "// unbind UI elements", "this", ".", "unbindUIElements", "(", ")", ";", "// remove the view from the DOM", "this", ".", "remove", "(", ")", ";", "}" ]
Default `close` implementation, for removing a view from the DOM and unbinding it. Regions will call this method for you. You can specify an `onClose` method in your view to add custom code that is called after the view is closed.
[ "Default", "close", "implementation", "for", "removing", "a", "view", "from", "the", "DOM", "and", "unbinding", "it", ".", "Regions", "will", "call", "this", "method", "for", "you", ".", "You", "can", "specify", "an", "onClose", "method", "in", "your", "view", "to", "add", "custom", "code", "that", "is", "called", "after", "the", "view", "is", "closed", "." ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1315-L1336
44,527
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(){ if (!this.ui || !this._uiBindings){ return; } // delete all of the existing ui bindings _.each(this.ui, function($el, name){ delete this.ui[name]; }, this); // reset the ui element to the original bindings configuration this.ui = this._uiBindings; delete this._uiBindings; }
javascript
function(){ if (!this.ui || !this._uiBindings){ return; } // delete all of the existing ui bindings _.each(this.ui, function($el, name){ delete this.ui[name]; }, this); // reset the ui element to the original bindings configuration this.ui = this._uiBindings; delete this._uiBindings; }
[ "function", "(", ")", "{", "if", "(", "!", "this", ".", "ui", "||", "!", "this", ".", "_uiBindings", ")", "{", "return", ";", "}", "// delete all of the existing ui bindings", "_", ".", "each", "(", "this", ".", "ui", ",", "function", "(", "$el", ",", "name", ")", "{", "delete", "this", ".", "ui", "[", "name", "]", ";", "}", ",", "this", ")", ";", "// reset the ui element to the original bindings configuration", "this", ".", "ui", "=", "this", ".", "_uiBindings", ";", "delete", "this", ".", "_uiBindings", ";", "}" ]
This method unbinds the elements specified in the "ui" hash
[ "This", "method", "unbinds", "the", "elements", "specified", "in", "the", "ui", "hash" ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1363-L1374
44,528
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(){ this.isClosed = false; this.triggerMethod("before:render", this); this.triggerMethod("item:before:render", this); var data = this.serializeData(); data = this.mixinTemplateHelpers(data); var template = this.getTemplate(); var html = Marionette.Renderer.render(template, data); this.$el.html(html); this.bindUIElements(); this.triggerMethod("render", this); this.triggerMethod("item:rendered", this); return this; }
javascript
function(){ this.isClosed = false; this.triggerMethod("before:render", this); this.triggerMethod("item:before:render", this); var data = this.serializeData(); data = this.mixinTemplateHelpers(data); var template = this.getTemplate(); var html = Marionette.Renderer.render(template, data); this.$el.html(html); this.bindUIElements(); this.triggerMethod("render", this); this.triggerMethod("item:rendered", this); return this; }
[ "function", "(", ")", "{", "this", ".", "isClosed", "=", "false", ";", "this", ".", "triggerMethod", "(", "\"before:render\"", ",", "this", ")", ";", "this", ".", "triggerMethod", "(", "\"item:before:render\"", ",", "this", ")", ";", "var", "data", "=", "this", ".", "serializeData", "(", ")", ";", "data", "=", "this", ".", "mixinTemplateHelpers", "(", "data", ")", ";", "var", "template", "=", "this", ".", "getTemplate", "(", ")", ";", "var", "html", "=", "Marionette", ".", "Renderer", ".", "render", "(", "template", ",", "data", ")", ";", "this", ".", "$el", ".", "html", "(", "html", ")", ";", "this", ".", "bindUIElements", "(", ")", ";", "this", ".", "triggerMethod", "(", "\"render\"", ",", "this", ")", ";", "this", ".", "triggerMethod", "(", "\"item:rendered\"", ",", "this", ")", ";", "return", "this", ";", "}" ]
Render the view, defaulting to underscore.js templates. You can override this in your view definition to provide a very specific rendering for your view. In general, though, you should override the `Marionette.Renderer` object to change how Marionette renders views.
[ "Render", "the", "view", "defaulting", "to", "underscore", ".", "js", "templates", ".", "You", "can", "override", "this", "in", "your", "view", "definition", "to", "provide", "a", "very", "specific", "rendering", "for", "your", "view", ".", "In", "general", "though", "you", "should", "override", "the", "Marionette", ".", "Renderer", "object", "to", "change", "how", "Marionette", "renders", "views", "." ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1415-L1434
44,529
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(){ if (this.isClosed){ return; } this.triggerMethod('item:before:close'); Marionette.View.prototype.close.apply(this, slice(arguments)); this.triggerMethod('item:closed'); }
javascript
function(){ if (this.isClosed){ return; } this.triggerMethod('item:before:close'); Marionette.View.prototype.close.apply(this, slice(arguments)); this.triggerMethod('item:closed'); }
[ "function", "(", ")", "{", "if", "(", "this", ".", "isClosed", ")", "{", "return", ";", "}", "this", ".", "triggerMethod", "(", "'item:before:close'", ")", ";", "Marionette", ".", "View", ".", "prototype", ".", "close", ".", "apply", "(", "this", ",", "slice", "(", "arguments", ")", ")", ";", "this", ".", "triggerMethod", "(", "'item:closed'", ")", ";", "}" ]
Override the default close event to add a few more events that are triggered.
[ "Override", "the", "default", "close", "event", "to", "add", "a", "few", "more", "events", "that", "are", "triggered", "." ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1438-L1446
44,530
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(){ if (this.collection){ this.listenTo(this.collection, "add", this.addChildView, this); this.listenTo(this.collection, "remove", this.removeItemView, this); this.listenTo(this.collection, "reset", this.render, this); } }
javascript
function(){ if (this.collection){ this.listenTo(this.collection, "add", this.addChildView, this); this.listenTo(this.collection, "remove", this.removeItemView, this); this.listenTo(this.collection, "reset", this.render, this); } }
[ "function", "(", ")", "{", "if", "(", "this", ".", "collection", ")", "{", "this", ".", "listenTo", "(", "this", ".", "collection", ",", "\"add\"", ",", "this", ".", "addChildView", ",", "this", ")", ";", "this", ".", "listenTo", "(", "this", ".", "collection", ",", "\"remove\"", ",", "this", ".", "removeItemView", ",", "this", ")", ";", "this", ".", "listenTo", "(", "this", ".", "collection", ",", "\"reset\"", ",", "this", ".", "render", ",", "this", ")", ";", "}", "}" ]
Configured the initial events that the collection view binds to. Override this method to prevent the initial events, or to add your own initial events.
[ "Configured", "the", "initial", "events", "that", "the", "collection", "view", "binds", "to", ".", "Override", "this", "method", "to", "prevent", "the", "initial", "events", "or", "to", "add", "your", "own", "initial", "events", "." ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1471-L1477
44,531
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(item, collection, options){ this.closeEmptyView(); var ItemView = this.getItemView(item); var index = this.collection.indexOf(item); this.addItemView(item, ItemView, index); }
javascript
function(item, collection, options){ this.closeEmptyView(); var ItemView = this.getItemView(item); var index = this.collection.indexOf(item); this.addItemView(item, ItemView, index); }
[ "function", "(", "item", ",", "collection", ",", "options", ")", "{", "this", ".", "closeEmptyView", "(", ")", ";", "var", "ItemView", "=", "this", ".", "getItemView", "(", "item", ")", ";", "var", "index", "=", "this", ".", "collection", ".", "indexOf", "(", "item", ")", ";", "this", ".", "addItemView", "(", "item", ",", "ItemView", ",", "index", ")", ";", "}" ]
Handle a child item added to the collection
[ "Handle", "a", "child", "item", "added", "to", "the", "collection" ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1480-L1485
44,532
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(){ var ItemView; this.collection.each(function(item, index){ ItemView = this.getItemView(item); this.addItemView(item, ItemView, index); }, this); }
javascript
function(){ var ItemView; this.collection.each(function(item, index){ ItemView = this.getItemView(item); this.addItemView(item, ItemView, index); }, this); }
[ "function", "(", ")", "{", "var", "ItemView", ";", "this", ".", "collection", ".", "each", "(", "function", "(", "item", ",", "index", ")", "{", "ItemView", "=", "this", ".", "getItemView", "(", "item", ")", ";", "this", ".", "addItemView", "(", "item", ",", "ItemView", ",", "index", ")", ";", "}", ",", "this", ")", ";", "}" ]
Internal method to loop through each item in the collection view and show it
[ "Internal", "method", "to", "loop", "through", "each", "item", "in", "the", "collection", "view", "and", "show", "it" ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1536-L1542
44,533
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(){ var EmptyView = Marionette.getOption(this, "emptyView"); if (EmptyView && !this._showingEmptyView){ this._showingEmptyView = true; var model = new Backbone.Model(); this.addItemView(model, EmptyView, 0); } }
javascript
function(){ var EmptyView = Marionette.getOption(this, "emptyView"); if (EmptyView && !this._showingEmptyView){ this._showingEmptyView = true; var model = new Backbone.Model(); this.addItemView(model, EmptyView, 0); } }
[ "function", "(", ")", "{", "var", "EmptyView", "=", "Marionette", ".", "getOption", "(", "this", ",", "\"emptyView\"", ")", ";", "if", "(", "EmptyView", "&&", "!", "this", ".", "_showingEmptyView", ")", "{", "this", ".", "_showingEmptyView", "=", "true", ";", "var", "model", "=", "new", "Backbone", ".", "Model", "(", ")", ";", "this", ".", "addItemView", "(", "model", ",", "EmptyView", ",", "0", ")", ";", "}", "}" ]
Internal method to show an empty view in place of a collection of item views, when the collection is empty
[ "Internal", "method", "to", "show", "an", "empty", "view", "in", "place", "of", "a", "collection", "of", "item", "views", "when", "the", "collection", "is", "empty" ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1547-L1555
44,534
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(item, ItemView, index){ // get the itemViewOptions if any were specified var itemViewOptions = Marionette.getOption(this, "itemViewOptions"); if (_.isFunction(itemViewOptions)){ itemViewOptions = itemViewOptions.call(this, item, index); } // build the view var view = this.buildItemView(item, ItemView, itemViewOptions); // set up the child view event forwarding this.addChildViewEventForwarding(view); // this view is about to be added this.triggerMethod("before:item:added", view); // Store the child view itself so we can properly // remove and/or close it later this.children.add(view); // Render it and show it this.renderItemView(view, index); // call the "show" method if the collection view // has already been shown if (this._isShown){ Marionette.triggerMethod.call(view, "show"); } // this view was added this.triggerMethod("after:item:added", view); }
javascript
function(item, ItemView, index){ // get the itemViewOptions if any were specified var itemViewOptions = Marionette.getOption(this, "itemViewOptions"); if (_.isFunction(itemViewOptions)){ itemViewOptions = itemViewOptions.call(this, item, index); } // build the view var view = this.buildItemView(item, ItemView, itemViewOptions); // set up the child view event forwarding this.addChildViewEventForwarding(view); // this view is about to be added this.triggerMethod("before:item:added", view); // Store the child view itself so we can properly // remove and/or close it later this.children.add(view); // Render it and show it this.renderItemView(view, index); // call the "show" method if the collection view // has already been shown if (this._isShown){ Marionette.triggerMethod.call(view, "show"); } // this view was added this.triggerMethod("after:item:added", view); }
[ "function", "(", "item", ",", "ItemView", ",", "index", ")", "{", "// get the itemViewOptions if any were specified", "var", "itemViewOptions", "=", "Marionette", ".", "getOption", "(", "this", ",", "\"itemViewOptions\"", ")", ";", "if", "(", "_", ".", "isFunction", "(", "itemViewOptions", ")", ")", "{", "itemViewOptions", "=", "itemViewOptions", ".", "call", "(", "this", ",", "item", ",", "index", ")", ";", "}", "// build the view ", "var", "view", "=", "this", ".", "buildItemView", "(", "item", ",", "ItemView", ",", "itemViewOptions", ")", ";", "// set up the child view event forwarding", "this", ".", "addChildViewEventForwarding", "(", "view", ")", ";", "// this view is about to be added", "this", ".", "triggerMethod", "(", "\"before:item:added\"", ",", "view", ")", ";", "// Store the child view itself so we can properly", "// remove and/or close it later", "this", ".", "children", ".", "add", "(", "view", ")", ";", "// Render it and show it", "this", ".", "renderItemView", "(", "view", ",", "index", ")", ";", "// call the \"show\" method if the collection view", "// has already been shown", "if", "(", "this", ".", "_isShown", ")", "{", "Marionette", ".", "triggerMethod", ".", "call", "(", "view", ",", "\"show\"", ")", ";", "}", "// this view was added", "this", ".", "triggerMethod", "(", "\"after:item:added\"", ",", "view", ")", ";", "}" ]
Render the child item's view and add it to the HTML for the collection view.
[ "Render", "the", "child", "item", "s", "view", "and", "add", "it", "to", "the", "HTML", "for", "the", "collection", "view", "." ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1582-L1613
44,535
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(item, ItemViewType, itemViewOptions){ var options = _.extend({model: item}, itemViewOptions); return new ItemViewType(options); }
javascript
function(item, ItemViewType, itemViewOptions){ var options = _.extend({model: item}, itemViewOptions); return new ItemViewType(options); }
[ "function", "(", "item", ",", "ItemViewType", ",", "itemViewOptions", ")", "{", "var", "options", "=", "_", ".", "extend", "(", "{", "model", ":", "item", "}", ",", "itemViewOptions", ")", ";", "return", "new", "ItemViewType", "(", "options", ")", ";", "}" ]
Build an `itemView` for every model in the collection.
[ "Build", "an", "itemView", "for", "every", "model", "in", "the", "collection", "." ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1638-L1641
44,536
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(view){ // shut down the child view properly, // including events that the collection has from it if (view){ this.stopListening(view); // call 'close' or 'remove', depending on which is found if (view.close) { view.close(); } else if (view.remove) { view.remove(); } this.children.remove(view); } this.triggerMethod("item:removed", view); }
javascript
function(view){ // shut down the child view properly, // including events that the collection has from it if (view){ this.stopListening(view); // call 'close' or 'remove', depending on which is found if (view.close) { view.close(); } else if (view.remove) { view.remove(); } this.children.remove(view); } this.triggerMethod("item:removed", view); }
[ "function", "(", "view", ")", "{", "// shut down the child view properly,", "// including events that the collection has from it", "if", "(", "view", ")", "{", "this", ".", "stopListening", "(", "view", ")", ";", "// call 'close' or 'remove', depending on which is found", "if", "(", "view", ".", "close", ")", "{", "view", ".", "close", "(", ")", ";", "}", "else", "if", "(", "view", ".", "remove", ")", "{", "view", ".", "remove", "(", ")", ";", "}", "this", ".", "children", ".", "remove", "(", "view", ")", ";", "}", "this", ".", "triggerMethod", "(", "\"item:removed\"", ",", "view", ")", ";", "}" ]
Remove the child view and close it
[ "Remove", "the", "child", "view", "and", "close", "it" ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1651-L1666
44,537
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(){ if (this.collection){ this.listenTo(this.collection, "add", this.addChildView, this); this.listenTo(this.collection, "remove", this.removeItemView, this); this.listenTo(this.collection, "reset", this._renderChildren, this); } }
javascript
function(){ if (this.collection){ this.listenTo(this.collection, "add", this.addChildView, this); this.listenTo(this.collection, "remove", this.removeItemView, this); this.listenTo(this.collection, "reset", this._renderChildren, this); } }
[ "function", "(", ")", "{", "if", "(", "this", ".", "collection", ")", "{", "this", ".", "listenTo", "(", "this", ".", "collection", ",", "\"add\"", ",", "this", ".", "addChildView", ",", "this", ")", ";", "this", ".", "listenTo", "(", "this", ".", "collection", ",", "\"remove\"", ",", "this", ".", "removeItemView", ",", "this", ")", ";", "this", ".", "listenTo", "(", "this", ".", "collection", ",", "\"reset\"", ",", "this", ".", "_renderChildren", ",", "this", ")", ";", "}", "}" ]
Configured the initial events that the composite view binds to. Override this method to prevent the initial events, or to add your own initial events.
[ "Configured", "the", "initial", "events", "that", "the", "composite", "view", "binds", "to", ".", "Override", "this", "method", "to", "prevent", "the", "initial", "events", "or", "to", "add", "your", "own", "initial", "events", "." ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1730-L1736
44,538
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(){ this.isRendered = true; this.isClosed = false; this.resetItemViewContainer(); this.triggerBeforeRender(); var html = this.renderModel(); this.$el.html(html); // the ui bindings is done here and not at the end of render since they // will not be available until after the model is rendered, but should be // available before the collection is rendered. this.bindUIElements(); this.triggerMethod("composite:model:rendered"); this._renderChildren(); this.triggerMethod("composite:rendered"); this.triggerRendered(); return this; }
javascript
function(){ this.isRendered = true; this.isClosed = false; this.resetItemViewContainer(); this.triggerBeforeRender(); var html = this.renderModel(); this.$el.html(html); // the ui bindings is done here and not at the end of render since they // will not be available until after the model is rendered, but should be // available before the collection is rendered. this.bindUIElements(); this.triggerMethod("composite:model:rendered"); this._renderChildren(); this.triggerMethod("composite:rendered"); this.triggerRendered(); return this; }
[ "function", "(", ")", "{", "this", ".", "isRendered", "=", "true", ";", "this", ".", "isClosed", "=", "false", ";", "this", ".", "resetItemViewContainer", "(", ")", ";", "this", ".", "triggerBeforeRender", "(", ")", ";", "var", "html", "=", "this", ".", "renderModel", "(", ")", ";", "this", ".", "$el", ".", "html", "(", "html", ")", ";", "// the ui bindings is done here and not at the end of render since they", "// will not be available until after the model is rendered, but should be", "// available before the collection is rendered.", "this", ".", "bindUIElements", "(", ")", ";", "this", ".", "triggerMethod", "(", "\"composite:model:rendered\"", ")", ";", "this", ".", "_renderChildren", "(", ")", ";", "this", ".", "triggerMethod", "(", "\"composite:rendered\"", ")", ";", "this", ".", "triggerRendered", "(", ")", ";", "return", "this", ";", "}" ]
Renders the model once, and the collection once. Calling this again will tell the model's view to re-render itself but the collection will not re-render.
[ "Renders", "the", "model", "once", "and", "the", "collection", "once", ".", "Calling", "this", "again", "will", "tell", "the", "model", "s", "view", "to", "re", "-", "render", "itself", "but", "the", "collection", "will", "not", "re", "-", "render", "." ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1768-L1787
44,539
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function (options) { options = options || {}; this._firstRender = true; this._initializeRegions(options); Marionette.ItemView.prototype.constructor.call(this, options); }
javascript
function (options) { options = options || {}; this._firstRender = true; this._initializeRegions(options); Marionette.ItemView.prototype.constructor.call(this, options); }
[ "function", "(", "options", ")", "{", "options", "=", "options", "||", "{", "}", ";", "this", ".", "_firstRender", "=", "true", ";", "this", ".", "_initializeRegions", "(", "options", ")", ";", "Marionette", ".", "ItemView", ".", "prototype", ".", "constructor", ".", "call", "(", "this", ",", "options", ")", ";", "}" ]
Ensure the regions are available when the `initialize` method is called.
[ "Ensure", "the", "regions", "are", "available", "when", "the", "initialize", "method", "is", "called", "." ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1865-L1872
44,540
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(){ if (this.isClosed){ // a previously closed layout means we need to // completely re-initialize the regions this._initializeRegions(); } if (this._firstRender) { // if this is the first render, don't do anything to // reset the regions this._firstRender = false; } else if (!this.isClosed){ // If this is not the first render call, then we need to // re-initializing the `el` for each region this._reInitializeRegions(); } var args = Array.prototype.slice.apply(arguments); var result = Marionette.ItemView.prototype.render.apply(this, args); return result; }
javascript
function(){ if (this.isClosed){ // a previously closed layout means we need to // completely re-initialize the regions this._initializeRegions(); } if (this._firstRender) { // if this is the first render, don't do anything to // reset the regions this._firstRender = false; } else if (!this.isClosed){ // If this is not the first render call, then we need to // re-initializing the `el` for each region this._reInitializeRegions(); } var args = Array.prototype.slice.apply(arguments); var result = Marionette.ItemView.prototype.render.apply(this, args); return result; }
[ "function", "(", ")", "{", "if", "(", "this", ".", "isClosed", ")", "{", "// a previously closed layout means we need to ", "// completely re-initialize the regions", "this", ".", "_initializeRegions", "(", ")", ";", "}", "if", "(", "this", ".", "_firstRender", ")", "{", "// if this is the first render, don't do anything to", "// reset the regions", "this", ".", "_firstRender", "=", "false", ";", "}", "else", "if", "(", "!", "this", ".", "isClosed", ")", "{", "// If this is not the first render call, then we need to ", "// re-initializing the `el` for each region", "this", ".", "_reInitializeRegions", "(", ")", ";", "}", "var", "args", "=", "Array", ".", "prototype", ".", "slice", ".", "apply", "(", "arguments", ")", ";", "var", "result", "=", "Marionette", ".", "ItemView", ".", "prototype", ".", "render", ".", "apply", "(", "this", ",", "args", ")", ";", "return", "result", ";", "}" ]
Layout's render will use the existing region objects the first time it is called. Subsequent calls will close the views that the regions are showing and then reset the `el` for the regions to the newly rendered DOM elements.
[ "Layout", "s", "render", "will", "use", "the", "existing", "region", "objects", "the", "first", "time", "it", "is", "called", ".", "Subsequent", "calls", "will", "close", "the", "views", "that", "the", "regions", "are", "showing", "and", "then", "reset", "the", "el", "for", "the", "regions", "to", "the", "newly", "rendered", "DOM", "elements", "." ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1878-L1899
44,541
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function () { if (this.isClosed){ return; } this.regionManager.close(); var args = Array.prototype.slice.apply(arguments); Marionette.ItemView.prototype.close.apply(this, args); }
javascript
function () { if (this.isClosed){ return; } this.regionManager.close(); var args = Array.prototype.slice.apply(arguments); Marionette.ItemView.prototype.close.apply(this, args); }
[ "function", "(", ")", "{", "if", "(", "this", ".", "isClosed", ")", "{", "return", ";", "}", "this", ".", "regionManager", ".", "close", "(", ")", ";", "var", "args", "=", "Array", ".", "prototype", ".", "slice", ".", "apply", "(", "arguments", ")", ";", "Marionette", ".", "ItemView", ".", "prototype", ".", "close", ".", "apply", "(", "this", ",", "args", ")", ";", "}" ]
Handle closing regions, and then close the view itself.
[ "Handle", "closing", "regions", "and", "then", "close", "the", "view", "itself", "." ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1902-L1907
44,542
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(regions){ var that = this; var defaults = { regionType: Marionette.getOption(this, "regionType"), parentEl: function(){ return that.$el; } }; return this.regionManager.addRegions(regions, defaults); }
javascript
function(regions){ var that = this; var defaults = { regionType: Marionette.getOption(this, "regionType"), parentEl: function(){ return that.$el; } }; return this.regionManager.addRegions(regions, defaults); }
[ "function", "(", "regions", ")", "{", "var", "that", "=", "this", ";", "var", "defaults", "=", "{", "regionType", ":", "Marionette", ".", "getOption", "(", "this", ",", "\"regionType\"", ")", ",", "parentEl", ":", "function", "(", ")", "{", "return", "that", ".", "$el", ";", "}", "}", ";", "return", "this", ".", "regionManager", ".", "addRegions", "(", "regions", ",", "defaults", ")", ";", "}" ]
internal method to build regions
[ "internal", "method", "to", "build", "regions" ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1929-L1938
44,543
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function (options) { var regions; this._initRegionManager(); if (_.isFunction(this.regions)) { regions = this.regions(options); } else { regions = this.regions || {}; } this.addRegions(regions); }
javascript
function (options) { var regions; this._initRegionManager(); if (_.isFunction(this.regions)) { regions = this.regions(options); } else { regions = this.regions || {}; } this.addRegions(regions); }
[ "function", "(", "options", ")", "{", "var", "regions", ";", "this", ".", "_initRegionManager", "(", ")", ";", "if", "(", "_", ".", "isFunction", "(", "this", ".", "regions", ")", ")", "{", "regions", "=", "this", ".", "regions", "(", "options", ")", ";", "}", "else", "{", "regions", "=", "this", ".", "regions", "||", "{", "}", ";", "}", "this", ".", "addRegions", "(", "regions", ")", ";", "}" ]
Internal method to initialize the regions that have been defined in a `regions` attribute on this layout.
[ "Internal", "method", "to", "initialize", "the", "regions", "that", "have", "been", "defined", "in", "a", "regions", "attribute", "on", "this", "layout", "." ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1942-L1953
44,544
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(){ this.regionManager = new Marionette.RegionManager(); this.listenTo(this.regionManager, "region:add", function(name, region){ this[name] = region; this.trigger("region:add", name, region); }); this.listenTo(this.regionManager, "region:remove", function(name, region){ delete this[name]; this.trigger("region:remove", name, region); }); }
javascript
function(){ this.regionManager = new Marionette.RegionManager(); this.listenTo(this.regionManager, "region:add", function(name, region){ this[name] = region; this.trigger("region:add", name, region); }); this.listenTo(this.regionManager, "region:remove", function(name, region){ delete this[name]; this.trigger("region:remove", name, region); }); }
[ "function", "(", ")", "{", "this", ".", "regionManager", "=", "new", "Marionette", ".", "RegionManager", "(", ")", ";", "this", ".", "listenTo", "(", "this", ".", "regionManager", ",", "\"region:add\"", ",", "function", "(", "name", ",", "region", ")", "{", "this", "[", "name", "]", "=", "region", ";", "this", ".", "trigger", "(", "\"region:add\"", ",", "name", ",", "region", ")", ";", "}", ")", ";", "this", ".", "listenTo", "(", "this", ".", "regionManager", ",", "\"region:remove\"", ",", "function", "(", "name", ",", "region", ")", "{", "delete", "this", "[", "name", "]", ";", "this", ".", "trigger", "(", "\"region:remove\"", ",", "name", ",", "region", ")", ";", "}", ")", ";", "}" ]
Internal method to initialize the region manager and all regions in it
[ "Internal", "method", "to", "initialize", "the", "region", "manager", "and", "all", "regions", "in", "it" ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L1966-L1978
44,545
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(controller, appRoutes) { if (!appRoutes){ return; } var routeNames = _.keys(appRoutes).reverse(); // Backbone requires reverted order of routes _.each(routeNames, function(route) { this._addAppRoute(controller, route, appRoutes[route]); }, this); }
javascript
function(controller, appRoutes) { if (!appRoutes){ return; } var routeNames = _.keys(appRoutes).reverse(); // Backbone requires reverted order of routes _.each(routeNames, function(route) { this._addAppRoute(controller, route, appRoutes[route]); }, this); }
[ "function", "(", "controller", ",", "appRoutes", ")", "{", "if", "(", "!", "appRoutes", ")", "{", "return", ";", "}", "var", "routeNames", "=", "_", ".", "keys", "(", "appRoutes", ")", ".", "reverse", "(", ")", ";", "// Backbone requires reverted order of routes", "_", ".", "each", "(", "routeNames", ",", "function", "(", "route", ")", "{", "this", ".", "_addAppRoute", "(", "controller", ",", "route", ",", "appRoutes", "[", "route", "]", ")", ";", "}", ",", "this", ")", ";", "}" ]
Internal method to process the `appRoutes` for the router, and turn them in to routes that trigger the specified method on the specified `controller`.
[ "Internal", "method", "to", "process", "the", "appRoutes", "for", "the", "router", "and", "turn", "them", "in", "to", "routes", "that", "trigger", "the", "specified", "method", "on", "the", "specified", "controller", "." ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L2022-L2030
44,546
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(){ var args = Array.prototype.slice.apply(arguments); this.commands.execute.apply(this.commands, args); }
javascript
function(){ var args = Array.prototype.slice.apply(arguments); this.commands.execute.apply(this.commands, args); }
[ "function", "(", ")", "{", "var", "args", "=", "Array", ".", "prototype", ".", "slice", ".", "apply", "(", "arguments", ")", ";", "this", ".", "commands", ".", "execute", ".", "apply", "(", "this", ".", "commands", ",", "args", ")", ";", "}" ]
Command execution, facilitated by Backbone.Wreqr.Commands
[ "Command", "execution", "facilitated", "by", "Backbone", ".", "Wreqr", ".", "Commands" ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L2069-L2072
44,547
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(options){ this.triggerMethod("initialize:before", options); this._initCallbacks.run(options, this); this.triggerMethod("initialize:after", options); this.triggerMethod("start", options); }
javascript
function(options){ this.triggerMethod("initialize:before", options); this._initCallbacks.run(options, this); this.triggerMethod("initialize:after", options); this.triggerMethod("start", options); }
[ "function", "(", "options", ")", "{", "this", ".", "triggerMethod", "(", "\"initialize:before\"", ",", "options", ")", ";", "this", ".", "_initCallbacks", ".", "run", "(", "options", ",", "this", ")", ";", "this", ".", "triggerMethod", "(", "\"initialize:after\"", ",", "options", ")", ";", "this", ".", "triggerMethod", "(", "\"start\"", ",", "options", ")", ";", "}" ]
kick off all of the application's processes. initializes all of the regions that have been added to the app, and runs all of the initializer functions
[ "kick", "off", "all", "of", "the", "application", "s", "processes", ".", "initializes", "all", "of", "the", "regions", "that", "have", "been", "added", "to", "the", "app", "and", "runs", "all", "of", "the", "initializer", "functions" ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L2090-L2096
44,548
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(moduleNames, moduleDefinition){ // slice the args, and add this application object as the // first argument of the array var args = slice(arguments); args.unshift(this); // see the Marionette.Module object for more information return Marionette.Module.create.apply(Marionette.Module, args); }
javascript
function(moduleNames, moduleDefinition){ // slice the args, and add this application object as the // first argument of the array var args = slice(arguments); args.unshift(this); // see the Marionette.Module object for more information return Marionette.Module.create.apply(Marionette.Module, args); }
[ "function", "(", "moduleNames", ",", "moduleDefinition", ")", "{", "// slice the args, and add this application object as the", "// first argument of the array", "var", "args", "=", "slice", "(", "arguments", ")", ";", "args", ".", "unshift", "(", "this", ")", ";", "// see the Marionette.Module object for more information", "return", "Marionette", ".", "Module", ".", "create", ".", "apply", "(", "Marionette", ".", "Module", ",", "args", ")", ";", "}" ]
Create a module, attached to the application
[ "Create", "a", "module", "attached", "to", "the", "application" ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L2126-L2134
44,549
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(){ this._regionManager = new Marionette.RegionManager(); this.listenTo(this._regionManager, "region:add", function(name, region){ this[name] = region; }); this.listenTo(this._regionManager, "region:remove", function(name, region){ delete this[name]; }); }
javascript
function(){ this._regionManager = new Marionette.RegionManager(); this.listenTo(this._regionManager, "region:add", function(name, region){ this[name] = region; }); this.listenTo(this._regionManager, "region:remove", function(name, region){ delete this[name]; }); }
[ "function", "(", ")", "{", "this", ".", "_regionManager", "=", "new", "Marionette", ".", "RegionManager", "(", ")", ";", "this", ".", "listenTo", "(", "this", ".", "_regionManager", ",", "\"region:add\"", ",", "function", "(", "name", ",", "region", ")", "{", "this", "[", "name", "]", "=", "region", ";", "}", ")", ";", "this", ".", "listenTo", "(", "this", ".", "_regionManager", ",", "\"region:remove\"", ",", "function", "(", "name", ",", "region", ")", "{", "delete", "this", "[", "name", "]", ";", "}", ")", ";", "}" ]
Internal method to set up the region manager
[ "Internal", "method", "to", "set", "up", "the", "region", "manager" ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L2137-L2147
44,550
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(options){ // Prevent re-starting a module that is already started if (this._isInitialized){ return; } // start the sub-modules (depth-first hierarchy) _.each(this.submodules, function(mod){ // check to see if we should start the sub-module with this parent if (mod.startWithParent){ mod.start(options); } }); // run the callbacks to "start" the current module this.triggerMethod("before:start", options); this._initializerCallbacks.run(options, this); this._isInitialized = true; this.triggerMethod("start", options); }
javascript
function(options){ // Prevent re-starting a module that is already started if (this._isInitialized){ return; } // start the sub-modules (depth-first hierarchy) _.each(this.submodules, function(mod){ // check to see if we should start the sub-module with this parent if (mod.startWithParent){ mod.start(options); } }); // run the callbacks to "start" the current module this.triggerMethod("before:start", options); this._initializerCallbacks.run(options, this); this._isInitialized = true; this.triggerMethod("start", options); }
[ "function", "(", "options", ")", "{", "// Prevent re-starting a module that is already started", "if", "(", "this", ".", "_isInitialized", ")", "{", "return", ";", "}", "// start the sub-modules (depth-first hierarchy)", "_", ".", "each", "(", "this", ".", "submodules", ",", "function", "(", "mod", ")", "{", "// check to see if we should start the sub-module with this parent", "if", "(", "mod", ".", "startWithParent", ")", "{", "mod", ".", "start", "(", "options", ")", ";", "}", "}", ")", ";", "// run the callbacks to \"start\" the current module", "this", ".", "triggerMethod", "(", "\"before:start\"", ",", "options", ")", ";", "this", ".", "_initializerCallbacks", ".", "run", "(", "options", ",", "this", ")", ";", "this", ".", "_isInitialized", "=", "true", ";", "this", ".", "triggerMethod", "(", "\"start\"", ",", "options", ")", ";", "}" ]
Start the module, and run all of its initializers
[ "Start", "the", "module", "and", "run", "all", "of", "its", "initializers" ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L2191-L2210
44,551
jmorrell/backbone-filtered-collection
examples/map/js/backbone.marionette.js
function(){ // if we are not initialized, don't bother finalizing if (!this._isInitialized){ return; } this._isInitialized = false; Marionette.triggerMethod.call(this, "before:stop"); // stop the sub-modules; depth-first, to make sure the // sub-modules are stopped / finalized before parents _.each(this.submodules, function(mod){ mod.stop(); }); // run the finalizers this._finalizerCallbacks.run(undefined,this); // reset the initializers and finalizers this._initializerCallbacks.reset(); this._finalizerCallbacks.reset(); Marionette.triggerMethod.call(this, "stop"); }
javascript
function(){ // if we are not initialized, don't bother finalizing if (!this._isInitialized){ return; } this._isInitialized = false; Marionette.triggerMethod.call(this, "before:stop"); // stop the sub-modules; depth-first, to make sure the // sub-modules are stopped / finalized before parents _.each(this.submodules, function(mod){ mod.stop(); }); // run the finalizers this._finalizerCallbacks.run(undefined,this); // reset the initializers and finalizers this._initializerCallbacks.reset(); this._finalizerCallbacks.reset(); Marionette.triggerMethod.call(this, "stop"); }
[ "function", "(", ")", "{", "// if we are not initialized, don't bother finalizing", "if", "(", "!", "this", ".", "_isInitialized", ")", "{", "return", ";", "}", "this", ".", "_isInitialized", "=", "false", ";", "Marionette", ".", "triggerMethod", ".", "call", "(", "this", ",", "\"before:stop\"", ")", ";", "// stop the sub-modules; depth-first, to make sure the", "// sub-modules are stopped / finalized before parents", "_", ".", "each", "(", "this", ".", "submodules", ",", "function", "(", "mod", ")", "{", "mod", ".", "stop", "(", ")", ";", "}", ")", ";", "// run the finalizers", "this", ".", "_finalizerCallbacks", ".", "run", "(", "undefined", ",", "this", ")", ";", "// reset the initializers and finalizers", "this", ".", "_initializerCallbacks", ".", "reset", "(", ")", ";", "this", ".", "_finalizerCallbacks", ".", "reset", "(", ")", ";", "Marionette", ".", "triggerMethod", ".", "call", "(", "this", ",", "\"stop\"", ")", ";", "}" ]
Stop this module by running its finalizers and then stop all of the sub-modules for this module
[ "Stop", "this", "module", "by", "running", "its", "finalizers", "and", "then", "stop", "all", "of", "the", "sub", "-", "modules", "for", "this", "module" ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/examples/map/js/backbone.marionette.js#L2214-L2233
44,552
pocka/bitwise64
index.js
divide
function divide(bit) { var bitString = ((zeros + zeros) + (Number(bit).toString(2))).slice(-64); return [ parseInt(bitString.slice(0, 32), 2), // hi parseInt(bitString.slice(-32), 2) // lo ]; }
javascript
function divide(bit) { var bitString = ((zeros + zeros) + (Number(bit).toString(2))).slice(-64); return [ parseInt(bitString.slice(0, 32), 2), // hi parseInt(bitString.slice(-32), 2) // lo ]; }
[ "function", "divide", "(", "bit", ")", "{", "var", "bitString", "=", "(", "(", "zeros", "+", "zeros", ")", "+", "(", "Number", "(", "bit", ")", ".", "toString", "(", "2", ")", ")", ")", ".", "slice", "(", "-", "64", ")", ";", "return", "[", "parseInt", "(", "bitString", ".", "slice", "(", "0", ",", "32", ")", ",", "2", ")", ",", "// hi", "parseInt", "(", "bitString", ".", "slice", "(", "-", "32", ")", ",", "2", ")", "// lo", "]", ";", "}" ]
Divides hi and lo
[ "Divides", "hi", "and", "lo" ]
fe6c2c0fd6072d3c37790bc10fe2f8e9c51553f3
https://github.com/pocka/bitwise64/blob/fe6c2c0fd6072d3c37790bc10fe2f8e9c51553f3/index.js#L13-L20
44,553
doowb/set-getter
index.js
setGetter
function setGetter(obj, prop, getter) { var key = toPath(arguments); return define(obj, key, getter); }
javascript
function setGetter(obj, prop, getter) { var key = toPath(arguments); return define(obj, key, getter); }
[ "function", "setGetter", "(", "obj", ",", "prop", ",", "getter", ")", "{", "var", "key", "=", "toPath", "(", "arguments", ")", ";", "return", "define", "(", "obj", ",", "key", ",", "getter", ")", ";", "}" ]
Defines a getter function on an object using property path notation. ```js var obj = {}; getter(obj, 'foo', function() { return 'bar'; }); ``` @param {Object} `obj` Object to add property to. @param {String|Array} `prop` Property string or array to add. @param {Function} `getter` Getter function to add as a property. @api public
[ "Defines", "a", "getter", "function", "on", "an", "object", "using", "property", "path", "notation", "." ]
5bc2750fe1c3db9651d936131be187744111378d
https://github.com/doowb/set-getter/blob/5bc2750fe1c3db9651d936131be187744111378d/index.js#L27-L30
44,554
doowb/set-getter
index.js
define
function define(obj, prop, getter) { if (!~prop.indexOf('.')) { defineProperty(obj, prop, getter); return obj; } var keys = prop.split('.'); var last = keys.pop(); var target = obj; var key; while ((key = keys.shift())) { while (key.slice(-1) === '\\') { key = key.slice(0, -1) + '.' + keys.shift(); } target = target[key] || (target[key] = {}); } defineProperty(target, last, getter); return obj; }
javascript
function define(obj, prop, getter) { if (!~prop.indexOf('.')) { defineProperty(obj, prop, getter); return obj; } var keys = prop.split('.'); var last = keys.pop(); var target = obj; var key; while ((key = keys.shift())) { while (key.slice(-1) === '\\') { key = key.slice(0, -1) + '.' + keys.shift(); } target = target[key] || (target[key] = {}); } defineProperty(target, last, getter); return obj; }
[ "function", "define", "(", "obj", ",", "prop", ",", "getter", ")", "{", "if", "(", "!", "~", "prop", ".", "indexOf", "(", "'.'", ")", ")", "{", "defineProperty", "(", "obj", ",", "prop", ",", "getter", ")", ";", "return", "obj", ";", "}", "var", "keys", "=", "prop", ".", "split", "(", "'.'", ")", ";", "var", "last", "=", "keys", ".", "pop", "(", ")", ";", "var", "target", "=", "obj", ";", "var", "key", ";", "while", "(", "(", "key", "=", "keys", ".", "shift", "(", ")", ")", ")", "{", "while", "(", "key", ".", "slice", "(", "-", "1", ")", "===", "'\\\\'", ")", "{", "key", "=", "key", ".", "slice", "(", "0", ",", "-", "1", ")", "+", "'.'", "+", "keys", ".", "shift", "(", ")", ";", "}", "target", "=", "target", "[", "key", "]", "||", "(", "target", "[", "key", "]", "=", "{", "}", ")", ";", "}", "defineProperty", "(", "target", ",", "last", ",", "getter", ")", ";", "return", "obj", ";", "}" ]
Define getter function on object or object hierarchy using dot notation. @param {Object} `obj` Object to define getter property on. @param {String} `prop` Property string to define. @param {Function} `getter` Getter function to define. @return {Object} Returns original object.
[ "Define", "getter", "function", "on", "object", "or", "object", "hierarchy", "using", "dot", "notation", "." ]
5bc2750fe1c3db9651d936131be187744111378d
https://github.com/doowb/set-getter/blob/5bc2750fe1c3db9651d936131be187744111378d/index.js#L41-L61
44,555
doowb/set-getter
index.js
defineProperty
function defineProperty(obj, prop, getter) { Object.defineProperty(obj, prop, { configurable: true, enumerable: true, get: getter }); }
javascript
function defineProperty(obj, prop, getter) { Object.defineProperty(obj, prop, { configurable: true, enumerable: true, get: getter }); }
[ "function", "defineProperty", "(", "obj", ",", "prop", ",", "getter", ")", "{", "Object", ".", "defineProperty", "(", "obj", ",", "prop", ",", "{", "configurable", ":", "true", ",", "enumerable", ":", "true", ",", "get", ":", "getter", "}", ")", ";", "}" ]
Define getter function on object as a configurable and enumerable property. @param {Object} `obj` Object to define property on. @param {String} `prop` Property to define. @param {Function} `getter` Getter function to define.
[ "Define", "getter", "function", "on", "object", "as", "a", "configurable", "and", "enumerable", "property", "." ]
5bc2750fe1c3db9651d936131be187744111378d
https://github.com/doowb/set-getter/blob/5bc2750fe1c3db9651d936131be187744111378d/index.js#L71-L77
44,556
jmorrell/backbone-filtered-collection
src/create-filter.js
function(model) { for (var i = 0; i < filterFunctions.length; i++) { if (!filterFunctions[i](model)) { return false; } } return true; }
javascript
function(model) { for (var i = 0; i < filterFunctions.length; i++) { if (!filterFunctions[i](model)) { return false; } } return true; }
[ "function", "(", "model", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "filterFunctions", ".", "length", ";", "i", "++", ")", "{", "if", "(", "!", "filterFunctions", "[", "i", "]", "(", "model", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Iterate through each of the generated filter functions. If any are false, kill the computation and return false. The function is only true if all of the subfunctions are true.
[ "Iterate", "through", "each", "of", "the", "generated", "filter", "functions", ".", "If", "any", "are", "false", "kill", "the", "computation", "and", "return", "false", ".", "The", "function", "is", "only", "true", "if", "all", "of", "the", "subfunctions", "are", "true", "." ]
880672e7edbc3eb2151f569fe009d62d03d989c4
https://github.com/jmorrell/backbone-filtered-collection/blob/880672e7edbc3eb2151f569fe009d62d03d989c4/src/create-filter.js#L50-L57
44,557
darren-lester/nihongo
src/analysers.js
isKyouikuKanji
function isKyouikuKanji(ch) { return includes(kyouikuKanji.grade1, ch) || includes(kyouikuKanji.grade2, ch) || includes(kyouikuKanji.grade3, ch) || includes(kyouikuKanji.grade4, ch) || includes(kyouikuKanji.grade5, ch) || includes(kyouikuKanji.grade6, ch); }
javascript
function isKyouikuKanji(ch) { return includes(kyouikuKanji.grade1, ch) || includes(kyouikuKanji.grade2, ch) || includes(kyouikuKanji.grade3, ch) || includes(kyouikuKanji.grade4, ch) || includes(kyouikuKanji.grade5, ch) || includes(kyouikuKanji.grade6, ch); }
[ "function", "isKyouikuKanji", "(", "ch", ")", "{", "return", "includes", "(", "kyouikuKanji", ".", "grade1", ",", "ch", ")", "||", "includes", "(", "kyouikuKanji", ".", "grade2", ",", "ch", ")", "||", "includes", "(", "kyouikuKanji", ".", "grade3", ",", "ch", ")", "||", "includes", "(", "kyouikuKanji", ".", "grade4", ",", "ch", ")", "||", "includes", "(", "kyouikuKanji", ".", "grade5", ",", "ch", ")", "||", "includes", "(", "kyouikuKanji", ".", "grade6", ",", "ch", ")", ";", "}" ]
determine whether a character is a kyouiku kanji character
[ "determine", "whether", "a", "character", "is", "a", "kyouiku", "kanji", "character" ]
2ca0fbfac7aa41c8b5d8476fc6da0ab1f0ea27e7
https://github.com/darren-lester/nihongo/blob/2ca0fbfac7aa41c8b5d8476fc6da0ab1f0ea27e7/src/analysers.js#L36-L43
44,558
darren-lester/nihongo
src/analysers.js
getKyouikuGrade
function getKyouikuGrade(ch) { let grade; if (includes(kyouikuKanji.grade1, ch)) { grade = 1; } else if (includes(kyouikuKanji.grade2, ch)) { grade = 2; } else if (includes(kyouikuKanji.grade3, ch)) { grade = 3; } else if (includes(kyouikuKanji.grade4, ch)) { grade = 4; } else if (includes(kyouikuKanji.grade5, ch)) { grade = 5; } else if (includes(kyouikuKanji.grade6, ch)) { grade = 6; } return grade; }
javascript
function getKyouikuGrade(ch) { let grade; if (includes(kyouikuKanji.grade1, ch)) { grade = 1; } else if (includes(kyouikuKanji.grade2, ch)) { grade = 2; } else if (includes(kyouikuKanji.grade3, ch)) { grade = 3; } else if (includes(kyouikuKanji.grade4, ch)) { grade = 4; } else if (includes(kyouikuKanji.grade5, ch)) { grade = 5; } else if (includes(kyouikuKanji.grade6, ch)) { grade = 6; } return grade; }
[ "function", "getKyouikuGrade", "(", "ch", ")", "{", "let", "grade", ";", "if", "(", "includes", "(", "kyouikuKanji", ".", "grade1", ",", "ch", ")", ")", "{", "grade", "=", "1", ";", "}", "else", "if", "(", "includes", "(", "kyouikuKanji", ".", "grade2", ",", "ch", ")", ")", "{", "grade", "=", "2", ";", "}", "else", "if", "(", "includes", "(", "kyouikuKanji", ".", "grade3", ",", "ch", ")", ")", "{", "grade", "=", "3", ";", "}", "else", "if", "(", "includes", "(", "kyouikuKanji", ".", "grade4", ",", "ch", ")", ")", "{", "grade", "=", "4", ";", "}", "else", "if", "(", "includes", "(", "kyouikuKanji", ".", "grade5", ",", "ch", ")", ")", "{", "grade", "=", "5", ";", "}", "else", "if", "(", "includes", "(", "kyouikuKanji", ".", "grade6", ",", "ch", ")", ")", "{", "grade", "=", "6", ";", "}", "return", "grade", ";", "}" ]
return the grade of a kyouiku kanji
[ "return", "the", "grade", "of", "a", "kyouiku", "kanji" ]
2ca0fbfac7aa41c8b5d8476fc6da0ab1f0ea27e7
https://github.com/darren-lester/nihongo/blob/2ca0fbfac7aa41c8b5d8476fc6da0ab1f0ea27e7/src/analysers.js#L51-L74
44,559
darren-lester/nihongo
src/analysers.js
contains
function contains(str) { return { hiragana: hasHiragana(str), katakana: hasKatakana(str), kanji: hasKanji(str) }; }
javascript
function contains(str) { return { hiragana: hasHiragana(str), katakana: hasKatakana(str), kanji: hasKanji(str) }; }
[ "function", "contains", "(", "str", ")", "{", "return", "{", "hiragana", ":", "hasHiragana", "(", "str", ")", ",", "katakana", ":", "hasKatakana", "(", "str", ")", ",", "kanji", ":", "hasKanji", "(", "str", ")", "}", ";", "}" ]
determine whether a string contains hiragana, katakana or kanji characters
[ "determine", "whether", "a", "string", "contains", "hiragana", "katakana", "or", "kanji", "characters" ]
2ca0fbfac7aa41c8b5d8476fc6da0ab1f0ea27e7
https://github.com/darren-lester/nihongo/blob/2ca0fbfac7aa41c8b5d8476fc6da0ab1f0ea27e7/src/analysers.js#L103-L109
44,560
tunnckoCore/acorn-extract-comments
index.js
acornExtractComments
function acornExtractComments (input, opts) { if (typeof input !== 'string') { throw new TypeError('acorn-extract-comments expect `input` to be a string') } if (!input.length) return [] opts = extend({ ast: false, line: false, block: false, preserve: false, locations: false, ecmaVersion: 6 }, opts) var comments = opts.onComment = [] var ast = acorn.parse(stripShebang(input), opts) if (!comments.length) return [] comments = filter(comments, function (comment) { var line = (opts.line && comment.type === 'Line') || false var block = (opts.block && comment.type === 'Block') || false var ignore = false if (typeof opts.preserve === 'boolean') { ignore = opts.preserve && defaultIsIgnore(comment.value) } if (typeof opts.preserve === 'function') { var preserve = opts.preserve(comment.value) ignore = typeof preserve === 'boolean' ? preserve : ignore } if (!ignore && line) return true if (!ignore && block) return true return false }) comments.ast = opts.ast && ast || undefined return comments }
javascript
function acornExtractComments (input, opts) { if (typeof input !== 'string') { throw new TypeError('acorn-extract-comments expect `input` to be a string') } if (!input.length) return [] opts = extend({ ast: false, line: false, block: false, preserve: false, locations: false, ecmaVersion: 6 }, opts) var comments = opts.onComment = [] var ast = acorn.parse(stripShebang(input), opts) if (!comments.length) return [] comments = filter(comments, function (comment) { var line = (opts.line && comment.type === 'Line') || false var block = (opts.block && comment.type === 'Block') || false var ignore = false if (typeof opts.preserve === 'boolean') { ignore = opts.preserve && defaultIsIgnore(comment.value) } if (typeof opts.preserve === 'function') { var preserve = opts.preserve(comment.value) ignore = typeof preserve === 'boolean' ? preserve : ignore } if (!ignore && line) return true if (!ignore && block) return true return false }) comments.ast = opts.ast && ast || undefined return comments }
[ "function", "acornExtractComments", "(", "input", ",", "opts", ")", "{", "if", "(", "typeof", "input", "!==", "'string'", ")", "{", "throw", "new", "TypeError", "(", "'acorn-extract-comments expect `input` to be a string'", ")", "}", "if", "(", "!", "input", ".", "length", ")", "return", "[", "]", "opts", "=", "extend", "(", "{", "ast", ":", "false", ",", "line", ":", "false", ",", "block", ":", "false", ",", "preserve", ":", "false", ",", "locations", ":", "false", ",", "ecmaVersion", ":", "6", "}", ",", "opts", ")", "var", "comments", "=", "opts", ".", "onComment", "=", "[", "]", "var", "ast", "=", "acorn", ".", "parse", "(", "stripShebang", "(", "input", ")", ",", "opts", ")", "if", "(", "!", "comments", ".", "length", ")", "return", "[", "]", "comments", "=", "filter", "(", "comments", ",", "function", "(", "comment", ")", "{", "var", "line", "=", "(", "opts", ".", "line", "&&", "comment", ".", "type", "===", "'Line'", ")", "||", "false", "var", "block", "=", "(", "opts", ".", "block", "&&", "comment", ".", "type", "===", "'Block'", ")", "||", "false", "var", "ignore", "=", "false", "if", "(", "typeof", "opts", ".", "preserve", "===", "'boolean'", ")", "{", "ignore", "=", "opts", ".", "preserve", "&&", "defaultIsIgnore", "(", "comment", ".", "value", ")", "}", "if", "(", "typeof", "opts", ".", "preserve", "===", "'function'", ")", "{", "var", "preserve", "=", "opts", ".", "preserve", "(", "comment", ".", "value", ")", "ignore", "=", "typeof", "preserve", "===", "'boolean'", "?", "preserve", ":", "ignore", "}", "if", "(", "!", "ignore", "&&", "line", ")", "return", "true", "if", "(", "!", "ignore", "&&", "block", ")", "return", "true", "return", "false", "}", ")", "comments", ".", "ast", "=", "opts", ".", "ast", "&&", "ast", "||", "undefined", "return", "comments", "}" ]
> Core logic to extract comments @param {String} `<input>` string from which to get comments @param {Object} `[opts]` optional options, passed to `acorn` @return {Array} can have `.ast` property if `opts.ast: true` @api private
[ ">", "Core", "logic", "to", "extract", "comments" ]
bcf965d8c85c1a0618348dbdb9f00b3af2591850
https://github.com/tunnckoCore/acorn-extract-comments/blob/bcf965d8c85c1a0618348dbdb9f00b3af2591850/index.js#L111-L150
44,561
Cloudstek/alfred-hugo
examples/file-cache.js
processComments
function processComments(file) { let data = JSON.parse(file); return data.map(x => ({ title: x.name, subtitle: x.email, arg: x.id, valid: true })); }
javascript
function processComments(file) { let data = JSON.parse(file); return data.map(x => ({ title: x.name, subtitle: x.email, arg: x.id, valid: true })); }
[ "function", "processComments", "(", "file", ")", "{", "let", "data", "=", "JSON", ".", "parse", "(", "file", ")", ";", "return", "data", ".", "map", "(", "x", "=>", "(", "{", "title", ":", "x", ".", "name", ",", "subtitle", ":", "x", ".", "email", ",", "arg", ":", "x", ".", "id", ",", "valid", ":", "true", "}", ")", ")", ";", "}" ]
My fancy processing function that takes longer than I'd like to complete @param {string} file Input file @return {Object}
[ "My", "fancy", "processing", "function", "that", "takes", "longer", "than", "I", "d", "like", "to", "complete" ]
e7b0da032be0ca9fd272f02247b843b8f15db0ff
https://github.com/Cloudstek/alfred-hugo/blob/e7b0da032be0ca9fd272f02247b843b8f15db0ff/examples/file-cache.js#L35-L44
44,562
mobify/pinny
dist/pinny.js
function(divisor) { var coverage; var percent = this.options.coverage.match(/(\d*)%$/); if (percent) { coverage = 100 - parseInt(percent[1]); if (divisor) { coverage = coverage / divisor; } } return percent ? coverage + '%' : this.options.coverage; }
javascript
function(divisor) { var coverage; var percent = this.options.coverage.match(/(\d*)%$/); if (percent) { coverage = 100 - parseInt(percent[1]); if (divisor) { coverage = coverage / divisor; } } return percent ? coverage + '%' : this.options.coverage; }
[ "function", "(", "divisor", ")", "{", "var", "coverage", ";", "var", "percent", "=", "this", ".", "options", ".", "coverage", ".", "match", "(", "/", "(\\d*)%$", "/", ")", ";", "if", "(", "percent", ")", "{", "coverage", "=", "100", "-", "parseInt", "(", "percent", "[", "1", "]", ")", ";", "if", "(", "divisor", ")", "{", "coverage", "=", "coverage", "/", "divisor", ";", "}", "}", "return", "percent", "?", "coverage", "+", "'%'", ":", "this", ".", "options", ".", "coverage", ";", "}" ]
Takes the coverage option and turns it into a effect value
[ "Takes", "the", "coverage", "option", "and", "turns", "it", "into", "a", "effect", "value" ]
ffa8e340eb50e6ff27126c75f54d6ff3edfa5d82
https://github.com/mobify/pinny/blob/ffa8e340eb50e6ff27126c75f54d6ff3edfa5d82/dist/pinny.js#L373-L386
44,563
mobify/pinny
dist/pinny.js
function() { // If lockup is already locked don't try to disable inputs again if (this.$pinny.lockup('isLocked')) { return; } var $focusableElements = $(FOCUSABLE_ELEMENTS).not(function() { return $(this).isChildOf('.' + classes.PINNY); }); $focusableElements.each(function(_, el) { var $el = $(el); var currentTabIndex = $el.attr('tabindex') || 0; $el .attr('data-orig-tabindex', currentTabIndex) .attr('tabindex', '-1'); }); }
javascript
function() { // If lockup is already locked don't try to disable inputs again if (this.$pinny.lockup('isLocked')) { return; } var $focusableElements = $(FOCUSABLE_ELEMENTS).not(function() { return $(this).isChildOf('.' + classes.PINNY); }); $focusableElements.each(function(_, el) { var $el = $(el); var currentTabIndex = $el.attr('tabindex') || 0; $el .attr('data-orig-tabindex', currentTabIndex) .attr('tabindex', '-1'); }); }
[ "function", "(", ")", "{", "// If lockup is already locked don't try to disable inputs again", "if", "(", "this", ".", "$pinny", ".", "lockup", "(", "'isLocked'", ")", ")", "{", "return", ";", "}", "var", "$focusableElements", "=", "$", "(", "FOCUSABLE_ELEMENTS", ")", ".", "not", "(", "function", "(", ")", "{", "return", "$", "(", "this", ")", ".", "isChildOf", "(", "'.'", "+", "classes", ".", "PINNY", ")", ";", "}", ")", ";", "$focusableElements", ".", "each", "(", "function", "(", "_", ",", "el", ")", "{", "var", "$el", "=", "$", "(", "el", ")", ";", "var", "currentTabIndex", "=", "$el", ".", "attr", "(", "'tabindex'", ")", "||", "0", ";", "$el", ".", "attr", "(", "'data-orig-tabindex'", ",", "currentTabIndex", ")", ".", "attr", "(", "'tabindex'", ",", "'-1'", ")", ";", "}", ")", ";", "}" ]
Traps any tabbing within the visible Pinny window by disabling tabbing into all inputs outside of pinny using a negative tabindex.
[ "Traps", "any", "tabbing", "within", "the", "visible", "Pinny", "window", "by", "disabling", "tabbing", "into", "all", "inputs", "outside", "of", "pinny", "using", "a", "negative", "tabindex", "." ]
ffa8e340eb50e6ff27126c75f54d6ff3edfa5d82
https://github.com/mobify/pinny/blob/ffa8e340eb50e6ff27126c75f54d6ff3edfa5d82/dist/pinny.js#L432-L450
44,564
mobify/pinny
dist/pinny.js
function() { // At this point, this pinny has been closed and lockup has unlocked. // If there are any other pinny's open we don't want to re-enable the // inputs as they still require them to be disabled. if (this._activePinnies()) { return; } $('[data-orig-tabindex]').each(function(_, el) { var $el = $(el); var oldTabIndex = parseInt($el.attr('data-orig-tabindex')); if (oldTabIndex) { $el.attr('tabindex', oldTabIndex); } else { $el.removeAttr('tabindex'); } $el.removeAttr('data-orig-tabindex'); }); }
javascript
function() { // At this point, this pinny has been closed and lockup has unlocked. // If there are any other pinny's open we don't want to re-enable the // inputs as they still require them to be disabled. if (this._activePinnies()) { return; } $('[data-orig-tabindex]').each(function(_, el) { var $el = $(el); var oldTabIndex = parseInt($el.attr('data-orig-tabindex')); if (oldTabIndex) { $el.attr('tabindex', oldTabIndex); } else { $el.removeAttr('tabindex'); } $el.removeAttr('data-orig-tabindex'); }); }
[ "function", "(", ")", "{", "// At this point, this pinny has been closed and lockup has unlocked.", "// If there are any other pinny's open we don't want to re-enable the", "// inputs as they still require them to be disabled.", "if", "(", "this", ".", "_activePinnies", "(", ")", ")", "{", "return", ";", "}", "$", "(", "'[data-orig-tabindex]'", ")", ".", "each", "(", "function", "(", "_", ",", "el", ")", "{", "var", "$el", "=", "$", "(", "el", ")", ";", "var", "oldTabIndex", "=", "parseInt", "(", "$el", ".", "attr", "(", "'data-orig-tabindex'", ")", ")", ";", "if", "(", "oldTabIndex", ")", "{", "$el", ".", "attr", "(", "'tabindex'", ",", "oldTabIndex", ")", ";", "}", "else", "{", "$el", ".", "removeAttr", "(", "'tabindex'", ")", ";", "}", "$el", ".", "removeAttr", "(", "'data-orig-tabindex'", ")", ";", "}", ")", ";", "}" ]
Re-enables tabbing in inputs not inside Pinny's content
[ "Re", "-", "enables", "tabbing", "in", "inputs", "not", "inside", "Pinny", "s", "content" ]
ffa8e340eb50e6ff27126c75f54d6ff3edfa5d82
https://github.com/mobify/pinny/blob/ffa8e340eb50e6ff27126c75f54d6ff3edfa5d82/dist/pinny.js#L455-L475
44,565
darren-lester/nihongo
src/parsers.js
basicParser
function basicParser(condition, str) { let result = []; for (let i = 0; i < str.length; ++i) { if (condition(str[i])) { result.push(str[i]); } } return result; }
javascript
function basicParser(condition, str) { let result = []; for (let i = 0; i < str.length; ++i) { if (condition(str[i])) { result.push(str[i]); } } return result; }
[ "function", "basicParser", "(", "condition", ",", "str", ")", "{", "let", "result", "=", "[", "]", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "str", ".", "length", ";", "++", "i", ")", "{", "if", "(", "condition", "(", "str", "[", "i", "]", ")", ")", "{", "result", ".", "push", "(", "str", "[", "i", "]", ")", ";", "}", "}", "return", "result", ";", "}" ]
returns an array of all characters in a string that fulfill a condition
[ "returns", "an", "array", "of", "all", "characters", "in", "a", "string", "that", "fulfill", "a", "condition" ]
2ca0fbfac7aa41c8b5d8476fc6da0ab1f0ea27e7
https://github.com/darren-lester/nihongo/blob/2ca0fbfac7aa41c8b5d8476fc6da0ab1f0ea27e7/src/parsers.js#L10-L20
44,566
darren-lester/nihongo
src/parsers.js
accumulativeParser
function accumulativeParser(condition, str) { let accumulations = []; let accumulator = ""; for (let i = 0; i < str.length; ++i) { let ch = str[i]; if (condition(ch)) { accumulator += ch; } else if (accumulator !== "") { accumulations.push(accumulator); accumulator = ""; } } return accumulations; }
javascript
function accumulativeParser(condition, str) { let accumulations = []; let accumulator = ""; for (let i = 0; i < str.length; ++i) { let ch = str[i]; if (condition(ch)) { accumulator += ch; } else if (accumulator !== "") { accumulations.push(accumulator); accumulator = ""; } } return accumulations; }
[ "function", "accumulativeParser", "(", "condition", ",", "str", ")", "{", "let", "accumulations", "=", "[", "]", ";", "let", "accumulator", "=", "\"\"", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "str", ".", "length", ";", "++", "i", ")", "{", "let", "ch", "=", "str", "[", "i", "]", ";", "if", "(", "condition", "(", "ch", ")", ")", "{", "accumulator", "+=", "ch", ";", "}", "else", "if", "(", "accumulator", "!==", "\"\"", ")", "{", "accumulations", ".", "push", "(", "accumulator", ")", ";", "accumulator", "=", "\"\"", ";", "}", "}", "return", "accumulations", ";", "}" ]
returns an array of all sequences of characters in a string that fulfill a condition
[ "returns", "an", "array", "of", "all", "sequences", "of", "characters", "in", "a", "string", "that", "fulfill", "a", "condition" ]
2ca0fbfac7aa41c8b5d8476fc6da0ab1f0ea27e7
https://github.com/darren-lester/nihongo/blob/2ca0fbfac7aa41c8b5d8476fc6da0ab1f0ea27e7/src/parsers.js#L24-L40
44,567
mahirshah/css-property-parser
src/initialValueMap.js
computeInitialValue
function computeInitialValue(propertyName) { if (properties[propertyName] === undefined) return; // unknown property if (initialValueMap[propertyName]) return; // value is cached. let initialValue = properties[propertyName].initial; if (Array.isArray(initialValue)) { // it's a shorthand initialValue.forEach(computeInitialValue); initialValueMap[propertyName] = canonicalShorthandInitialValues[propertyName] || initialValue.map(v => initialValueMap[v]).join(' '); } else { // it's a string with the initial value. // the value may be nonsense though. if (ILLEGAL_INITIAL_VALUES.test(initialValue)) { initialValue = 'initial'; // safest legal value. } initialValueMap[propertyName] = initialValueOverrides[propertyName] || initialValue; } const propertyNames = getShorthandComputedProperties(propertyName, true); initialValueRecursiveMap[propertyName] = { [propertyName]: initialValueMap[propertyName] }; initialValueConcreteMap[propertyName] = { }; // In theory, the recursive calls to `computeInitialValue` above should be // enough to populate the cache for these calls. However, in the case of data // corruption of the initial property this could be a bad assumption. propertyNames.forEach((prop) => { initialValueRecursiveMap[propertyName][prop] = initialValueMap[prop]; if (!isShorthandProperty(prop)) { initialValueConcreteMap[propertyName][prop] = initialValueMap[prop]; } }); }
javascript
function computeInitialValue(propertyName) { if (properties[propertyName] === undefined) return; // unknown property if (initialValueMap[propertyName]) return; // value is cached. let initialValue = properties[propertyName].initial; if (Array.isArray(initialValue)) { // it's a shorthand initialValue.forEach(computeInitialValue); initialValueMap[propertyName] = canonicalShorthandInitialValues[propertyName] || initialValue.map(v => initialValueMap[v]).join(' '); } else { // it's a string with the initial value. // the value may be nonsense though. if (ILLEGAL_INITIAL_VALUES.test(initialValue)) { initialValue = 'initial'; // safest legal value. } initialValueMap[propertyName] = initialValueOverrides[propertyName] || initialValue; } const propertyNames = getShorthandComputedProperties(propertyName, true); initialValueRecursiveMap[propertyName] = { [propertyName]: initialValueMap[propertyName] }; initialValueConcreteMap[propertyName] = { }; // In theory, the recursive calls to `computeInitialValue` above should be // enough to populate the cache for these calls. However, in the case of data // corruption of the initial property this could be a bad assumption. propertyNames.forEach((prop) => { initialValueRecursiveMap[propertyName][prop] = initialValueMap[prop]; if (!isShorthandProperty(prop)) { initialValueConcreteMap[propertyName][prop] = initialValueMap[prop]; } }); }
[ "function", "computeInitialValue", "(", "propertyName", ")", "{", "if", "(", "properties", "[", "propertyName", "]", "===", "undefined", ")", "return", ";", "// unknown property", "if", "(", "initialValueMap", "[", "propertyName", "]", ")", "return", ";", "// value is cached.", "let", "initialValue", "=", "properties", "[", "propertyName", "]", ".", "initial", ";", "if", "(", "Array", ".", "isArray", "(", "initialValue", ")", ")", "{", "// it's a shorthand", "initialValue", ".", "forEach", "(", "computeInitialValue", ")", ";", "initialValueMap", "[", "propertyName", "]", "=", "canonicalShorthandInitialValues", "[", "propertyName", "]", "||", "initialValue", ".", "map", "(", "v", "=>", "initialValueMap", "[", "v", "]", ")", ".", "join", "(", "' '", ")", ";", "}", "else", "{", "// it's a string with the initial value.", "// the value may be nonsense though.", "if", "(", "ILLEGAL_INITIAL_VALUES", ".", "test", "(", "initialValue", ")", ")", "{", "initialValue", "=", "'initial'", ";", "// safest legal value.", "}", "initialValueMap", "[", "propertyName", "]", "=", "initialValueOverrides", "[", "propertyName", "]", "||", "initialValue", ";", "}", "const", "propertyNames", "=", "getShorthandComputedProperties", "(", "propertyName", ",", "true", ")", ";", "initialValueRecursiveMap", "[", "propertyName", "]", "=", "{", "[", "propertyName", "]", ":", "initialValueMap", "[", "propertyName", "]", "}", ";", "initialValueConcreteMap", "[", "propertyName", "]", "=", "{", "}", ";", "// In theory, the recursive calls to `computeInitialValue` above should be", "// enough to populate the cache for these calls. However, in the case of data", "// corruption of the initial property this could be a bad assumption.", "propertyNames", ".", "forEach", "(", "(", "prop", ")", "=>", "{", "initialValueRecursiveMap", "[", "propertyName", "]", "[", "prop", "]", "=", "initialValueMap", "[", "prop", "]", ";", "if", "(", "!", "isShorthandProperty", "(", "prop", ")", ")", "{", "initialValueConcreteMap", "[", "propertyName", "]", "[", "prop", "]", "=", "initialValueMap", "[", "prop", "]", ";", "}", "}", ")", ";", "}" ]
Warms up the cache for a single property. @private @param {string} propertyName - the property name to warm up. @returns {void} this function runs for its side effects only.
[ "Warms", "up", "the", "cache", "for", "a", "single", "property", "." ]
012889d04e6b99f76352c9b6437c513e2ce54267
https://github.com/mahirshah/css-property-parser/blob/012889d04e6b99f76352c9b6437c513e2ce54267/src/initialValueMap.js#L115-L146
44,568
mahirshah/css-property-parser
src/initialValueMap.js
initialValues
function initialValues(property, recursivelyResolve = false, includeShorthands = false) { computeInitialValue(property); if (recursivelyResolve) { const initials = includeShorthands ? initialValueRecursiveMap[property] : initialValueConcreteMap[property]; if (!initials) { // It's an unknown property, return initial and hope the caller knows what // they are doing. return { [property]: 'initial' }; } // we make a copy here to prevent the caller from corrupting our cache. return Object.assign({}, initials); } return { [property]: initialValueMap[property] || 'initial' }; }
javascript
function initialValues(property, recursivelyResolve = false, includeShorthands = false) { computeInitialValue(property); if (recursivelyResolve) { const initials = includeShorthands ? initialValueRecursiveMap[property] : initialValueConcreteMap[property]; if (!initials) { // It's an unknown property, return initial and hope the caller knows what // they are doing. return { [property]: 'initial' }; } // we make a copy here to prevent the caller from corrupting our cache. return Object.assign({}, initials); } return { [property]: initialValueMap[property] || 'initial' }; }
[ "function", "initialValues", "(", "property", ",", "recursivelyResolve", "=", "false", ",", "includeShorthands", "=", "false", ")", "{", "computeInitialValue", "(", "property", ")", ";", "if", "(", "recursivelyResolve", ")", "{", "const", "initials", "=", "includeShorthands", "?", "initialValueRecursiveMap", "[", "property", "]", ":", "initialValueConcreteMap", "[", "property", "]", ";", "if", "(", "!", "initials", ")", "{", "// It's an unknown property, return initial and hope the caller knows what", "// they are doing.", "return", "{", "[", "property", "]", ":", "'initial'", "}", ";", "}", "// we make a copy here to prevent the caller from corrupting our cache.", "return", "Object", ".", "assign", "(", "{", "}", ",", "initials", ")", ";", "}", "return", "{", "[", "property", "]", ":", "initialValueMap", "[", "property", "]", "||", "'initial'", "}", ";", "}" ]
Get the initial values for a property. @param {string} property - the property name @param {boolean} recursivelyResolve - when given a shorthand property, causes the result to include long hand values. @param {boolean} includeShorthands - when resolving recursively, causes the the result to include the specified shorthand property as well as any intermediate shorthands of this property to to the initial value. @return {Object} the initial value or values a property has by default according the CSS specification. If the property's initial value(s) is/are unknown, the global keyword `initial` is returned. @example console.log(initialValues('border-width')); // => { 'border-width': 'medium' } console.log(initialValues('border-width', true)); // => { 'border-bottom-width': 'medium', 'border-left-width': 'medium', 'border-right-width': 'medium', 'border-top-width': 'medium', 'border-width': 'medium' }
[ "Get", "the", "initial", "values", "for", "a", "property", "." ]
012889d04e6b99f76352c9b6437c513e2ce54267
https://github.com/mahirshah/css-property-parser/blob/012889d04e6b99f76352c9b6437c513e2ce54267/src/initialValueMap.js#L181-L194
44,569
sweetcaptcha/sweetCaptcha-sdk-js
example.js
validateCaptcha
function validateCaptcha(captchaKey, captchaValue, callback) { // callback = function(err, isValid) {...} sweetcaptcha.api('check', {sckey: captchaKey, scvalue: captchaValue}, function(err, response){ if (err) return callback(err); if (response === 'true') { // valid captcha return callback(null, true); } // invalid captcha callback(null, false); }); }
javascript
function validateCaptcha(captchaKey, captchaValue, callback) { // callback = function(err, isValid) {...} sweetcaptcha.api('check', {sckey: captchaKey, scvalue: captchaValue}, function(err, response){ if (err) return callback(err); if (response === 'true') { // valid captcha return callback(null, true); } // invalid captcha callback(null, false); }); }
[ "function", "validateCaptcha", "(", "captchaKey", ",", "captchaValue", ",", "callback", ")", "{", "// callback = function(err, isValid) {...}", "sweetcaptcha", ".", "api", "(", "'check'", ",", "{", "sckey", ":", "captchaKey", ",", "scvalue", ":", "captchaValue", "}", ",", "function", "(", "err", ",", "response", ")", "{", "if", "(", "err", ")", "return", "callback", "(", "err", ")", ";", "if", "(", "response", "===", "'true'", ")", "{", "// valid captcha", "return", "callback", "(", "null", ",", "true", ")", ";", "}", "// invalid captcha", "callback", "(", "null", ",", "false", ")", ";", "}", ")", ";", "}" ]
Validate using sckey and scvalue, hidden inputs from previous HTML
[ "Validate", "using", "sckey", "and", "scvalue", "hidden", "inputs", "from", "previous", "HTML" ]
f58dd1b1bec69cfaefe6b6033b67eaee68b9cfce
https://github.com/sweetcaptcha/sweetCaptcha-sdk-js/blob/f58dd1b1bec69cfaefe6b6033b67eaee68b9cfce/example.js#L14-L30
44,570
tkellen/requirejs-library-skeleton
vendor/r.js
function (depMap, parent) { var mod = registry[depMap.id]; if (mod) { getModule(depMap).enable(); } }
javascript
function (depMap, parent) { var mod = registry[depMap.id]; if (mod) { getModule(depMap).enable(); } }
[ "function", "(", "depMap", ",", "parent", ")", "{", "var", "mod", "=", "registry", "[", "depMap", ".", "id", "]", ";", "if", "(", "mod", ")", "{", "getModule", "(", "depMap", ")", ".", "enable", "(", ")", ";", "}", "}" ]
Called to enable a module if it is still in the registry awaiting enablement. parent module is passed in for context, used by the optimizer.
[ "Called", "to", "enable", "a", "module", "if", "it", "is", "still", "in", "the", "registry", "awaiting", "enablement", ".", "parent", "module", "is", "passed", "in", "for", "context", "used", "by", "the", "optimizer", "." ]
c4ff186c588ba9418af71afb64cf7d000aa36bfb
https://github.com/tkellen/requirejs-library-skeleton/blob/c4ff186c588ba9418af71afb64cf7d000aa36bfb/vendor/r.js#L1549-L1554
44,571
tkellen/requirejs-library-skeleton
vendor/r.js
skipComment
function skipComment() { var ch, blockComment, lineComment; blockComment = false; lineComment = false; while (index < length) { ch = source[index]; if (lineComment) { ch = nextChar(); if (isLineTerminator(ch)) { lineComment = false; if (ch === '\r' && source[index] === '\n') { ++index; } ++lineNumber; lineStart = index; } } else if (blockComment) { if (isLineTerminator(ch)) { if (ch === '\r' && source[index + 1] === '\n') { ++index; } ++lineNumber; ++index; lineStart = index; if (index >= length) { throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); } } else { ch = nextChar(); if (index >= length) { throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); } if (ch === '*') { ch = source[index]; if (ch === '/') { ++index; blockComment = false; } } } } else if (ch === '/') { ch = source[index + 1]; if (ch === '/') { index += 2; lineComment = true; } else if (ch === '*') { index += 2; blockComment = true; if (index >= length) { throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); } } else { break; } } else if (isWhiteSpace(ch)) { ++index; } else if (isLineTerminator(ch)) { ++index; if (ch === '\r' && source[index] === '\n') { ++index; } ++lineNumber; lineStart = index; } else { break; } } }
javascript
function skipComment() { var ch, blockComment, lineComment; blockComment = false; lineComment = false; while (index < length) { ch = source[index]; if (lineComment) { ch = nextChar(); if (isLineTerminator(ch)) { lineComment = false; if (ch === '\r' && source[index] === '\n') { ++index; } ++lineNumber; lineStart = index; } } else if (blockComment) { if (isLineTerminator(ch)) { if (ch === '\r' && source[index + 1] === '\n') { ++index; } ++lineNumber; ++index; lineStart = index; if (index >= length) { throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); } } else { ch = nextChar(); if (index >= length) { throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); } if (ch === '*') { ch = source[index]; if (ch === '/') { ++index; blockComment = false; } } } } else if (ch === '/') { ch = source[index + 1]; if (ch === '/') { index += 2; lineComment = true; } else if (ch === '*') { index += 2; blockComment = true; if (index >= length) { throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); } } else { break; } } else if (isWhiteSpace(ch)) { ++index; } else if (isLineTerminator(ch)) { ++index; if (ch === '\r' && source[index] === '\n') { ++index; } ++lineNumber; lineStart = index; } else { break; } } }
[ "function", "skipComment", "(", ")", "{", "var", "ch", ",", "blockComment", ",", "lineComment", ";", "blockComment", "=", "false", ";", "lineComment", "=", "false", ";", "while", "(", "index", "<", "length", ")", "{", "ch", "=", "source", "[", "index", "]", ";", "if", "(", "lineComment", ")", "{", "ch", "=", "nextChar", "(", ")", ";", "if", "(", "isLineTerminator", "(", "ch", ")", ")", "{", "lineComment", "=", "false", ";", "if", "(", "ch", "===", "'\\r'", "&&", "source", "[", "index", "]", "===", "'\\n'", ")", "{", "++", "index", ";", "}", "++", "lineNumber", ";", "lineStart", "=", "index", ";", "}", "}", "else", "if", "(", "blockComment", ")", "{", "if", "(", "isLineTerminator", "(", "ch", ")", ")", "{", "if", "(", "ch", "===", "'\\r'", "&&", "source", "[", "index", "+", "1", "]", "===", "'\\n'", ")", "{", "++", "index", ";", "}", "++", "lineNumber", ";", "++", "index", ";", "lineStart", "=", "index", ";", "if", "(", "index", ">=", "length", ")", "{", "throwError", "(", "{", "}", ",", "Messages", ".", "UnexpectedToken", ",", "'ILLEGAL'", ")", ";", "}", "}", "else", "{", "ch", "=", "nextChar", "(", ")", ";", "if", "(", "index", ">=", "length", ")", "{", "throwError", "(", "{", "}", ",", "Messages", ".", "UnexpectedToken", ",", "'ILLEGAL'", ")", ";", "}", "if", "(", "ch", "===", "'*'", ")", "{", "ch", "=", "source", "[", "index", "]", ";", "if", "(", "ch", "===", "'/'", ")", "{", "++", "index", ";", "blockComment", "=", "false", ";", "}", "}", "}", "}", "else", "if", "(", "ch", "===", "'/'", ")", "{", "ch", "=", "source", "[", "index", "+", "1", "]", ";", "if", "(", "ch", "===", "'/'", ")", "{", "index", "+=", "2", ";", "lineComment", "=", "true", ";", "}", "else", "if", "(", "ch", "===", "'*'", ")", "{", "index", "+=", "2", ";", "blockComment", "=", "true", ";", "if", "(", "index", ">=", "length", ")", "{", "throwError", "(", "{", "}", ",", "Messages", ".", "UnexpectedToken", ",", "'ILLEGAL'", ")", ";", "}", "}", "else", "{", "break", ";", "}", "}", "else", "if", "(", "isWhiteSpace", "(", "ch", ")", ")", "{", "++", "index", ";", "}", "else", "if", "(", "isLineTerminator", "(", "ch", ")", ")", "{", "++", "index", ";", "if", "(", "ch", "===", "'\\r'", "&&", "source", "[", "index", "]", "===", "'\\n'", ")", "{", "++", "index", ";", "}", "++", "lineNumber", ";", "lineStart", "=", "index", ";", "}", "else", "{", "break", ";", "}", "}", "}" ]
7.4 Comments
[ "7", ".", "4", "Comments" ]
c4ff186c588ba9418af71afb64cf7d000aa36bfb
https://github.com/tkellen/requirejs-library-skeleton/blob/c4ff186c588ba9418af71afb64cf7d000aa36bfb/vendor/r.js#L3616-L3686
44,572
tkellen/requirejs-library-skeleton
vendor/r.js
addComment
function addComment(start, end, type, value) { assert(typeof start === 'number', 'Comment must have valid position'); // Because the way the actual token is scanned, often the comments // (if any) are skipped twice during the lexical analysis. // Thus, we need to skip adding a comment if the comment array already // handled it. if (extra.comments.length > 0) { if (extra.comments[extra.comments.length - 1].range[1] > start) { return; } } extra.comments.push({ range: [start, end], type: type, value: value }); }
javascript
function addComment(start, end, type, value) { assert(typeof start === 'number', 'Comment must have valid position'); // Because the way the actual token is scanned, often the comments // (if any) are skipped twice during the lexical analysis. // Thus, we need to skip adding a comment if the comment array already // handled it. if (extra.comments.length > 0) { if (extra.comments[extra.comments.length - 1].range[1] > start) { return; } } extra.comments.push({ range: [start, end], type: type, value: value }); }
[ "function", "addComment", "(", "start", ",", "end", ",", "type", ",", "value", ")", "{", "assert", "(", "typeof", "start", "===", "'number'", ",", "'Comment must have valid position'", ")", ";", "// Because the way the actual token is scanned, often the comments", "// (if any) are skipped twice during the lexical analysis.", "// Thus, we need to skip adding a comment if the comment array already", "// handled it.", "if", "(", "extra", ".", "comments", ".", "length", ">", "0", ")", "{", "if", "(", "extra", ".", "comments", "[", "extra", ".", "comments", ".", "length", "-", "1", "]", ".", "range", "[", "1", "]", ">", "start", ")", "{", "return", ";", "}", "}", "extra", ".", "comments", ".", "push", "(", "{", "range", ":", "[", "start", ",", "end", "]", ",", "type", ":", "type", ",", "value", ":", "value", "}", ")", ";", "}" ]
The following functions are needed only when the option to preserve the comments is active.
[ "The", "following", "functions", "are", "needed", "only", "when", "the", "option", "to", "preserve", "the", "comments", "is", "active", "." ]
c4ff186c588ba9418af71afb64cf7d000aa36bfb
https://github.com/tkellen/requirejs-library-skeleton/blob/c4ff186c588ba9418af71afb64cf7d000aa36bfb/vendor/r.js#L6323-L6341
44,573
mahirshah/css-property-parser
src/isInitialValue.js
isInitialValue
function isInitialValue(property, value) { const expanded = expandShorthandProperty(property, value, true, true); return Object.entries(expanded).every(([prop, val]) => { // eslint-disable-next-line no-param-reassign val = val.toLowerCase(); if (isShorthandProperty(prop)) return true; if (val === 'initial') return true; const canonicalInitialValue = initialValue(prop).toLowerCase(); if (val === canonicalInitialValue) return true; if (canonicalInitialValue === '0') { // all lengths if (/^0(px|mm|cm|in|pt|pc|q|mozmm)$/.test(val)) { return true; } } return false; }); }
javascript
function isInitialValue(property, value) { const expanded = expandShorthandProperty(property, value, true, true); return Object.entries(expanded).every(([prop, val]) => { // eslint-disable-next-line no-param-reassign val = val.toLowerCase(); if (isShorthandProperty(prop)) return true; if (val === 'initial') return true; const canonicalInitialValue = initialValue(prop).toLowerCase(); if (val === canonicalInitialValue) return true; if (canonicalInitialValue === '0') { // all lengths if (/^0(px|mm|cm|in|pt|pc|q|mozmm)$/.test(val)) { return true; } } return false; }); }
[ "function", "isInitialValue", "(", "property", ",", "value", ")", "{", "const", "expanded", "=", "expandShorthandProperty", "(", "property", ",", "value", ",", "true", ",", "true", ")", ";", "return", "Object", ".", "entries", "(", "expanded", ")", ".", "every", "(", "(", "[", "prop", ",", "val", "]", ")", "=>", "{", "// eslint-disable-next-line no-param-reassign", "val", "=", "val", ".", "toLowerCase", "(", ")", ";", "if", "(", "isShorthandProperty", "(", "prop", ")", ")", "return", "true", ";", "if", "(", "val", "===", "'initial'", ")", "return", "true", ";", "const", "canonicalInitialValue", "=", "initialValue", "(", "prop", ")", ".", "toLowerCase", "(", ")", ";", "if", "(", "val", "===", "canonicalInitialValue", ")", "return", "true", ";", "if", "(", "canonicalInitialValue", "===", "'0'", ")", "{", "// all lengths", "if", "(", "/", "^0(px|mm|cm|in|pt|pc|q|mozmm)$", "/", ".", "test", "(", "val", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}", ")", ";", "}" ]
Because of the `initial` keyword and shorthand expansion, there are many possible values that are equivalently identical with the initial value of a css property. This function returns true for all possible values that have the effect of setting a property to its initial value. @param {string} property the property to which the value is assigned @param {string} value the value to check @return {boolean} whether the value is equivalent to the initial value.
[ "Because", "of", "the", "initial", "keyword", "and", "shorthand", "expansion", "there", "are", "many", "possible", "values", "that", "are", "equivalently", "identical", "with", "the", "initial", "value", "of", "a", "css", "property", ".", "This", "function", "returns", "true", "for", "all", "possible", "values", "that", "have", "the", "effect", "of", "setting", "a", "property", "to", "its", "initial", "value", "." ]
012889d04e6b99f76352c9b6437c513e2ce54267
https://github.com/mahirshah/css-property-parser/blob/012889d04e6b99f76352c9b6437c513e2ce54267/src/isInitialValue.js#L16-L32
44,574
Smile-SA/grunt-build-html
tasks/buildHtml-retrieve-remote.js
function (fragmentKey, cachePath, skipCache, callback) { if (skipCache) { debug(' cache is disabled so...'); callback(false); } else { fs.exists(cachePath + '/' + fragmentKey, callback); } }
javascript
function (fragmentKey, cachePath, skipCache, callback) { if (skipCache) { debug(' cache is disabled so...'); callback(false); } else { fs.exists(cachePath + '/' + fragmentKey, callback); } }
[ "function", "(", "fragmentKey", ",", "cachePath", ",", "skipCache", ",", "callback", ")", "{", "if", "(", "skipCache", ")", "{", "debug", "(", "' cache is disabled so...'", ")", ";", "callback", "(", "false", ")", ";", "}", "else", "{", "fs", ".", "exists", "(", "cachePath", "+", "'/'", "+", "fragmentKey", ",", "callback", ")", ";", "}", "}" ]
Know if content is already in file system @param fragmentKey Remote content key @param cachePath Temp FS cache directory @param skipCache If false, attempt to retrieve remote content from files @param callback Method to call when data is retrieved
[ "Know", "if", "content", "is", "already", "in", "file", "system" ]
6fe1644ff6d08e0eada9482ae9dcdb0d4169ea2e
https://github.com/Smile-SA/grunt-build-html/blob/6fe1644ff6d08e0eada9482ae9dcdb0d4169ea2e/tasks/buildHtml-retrieve-remote.js#L26-L33
44,575
Smile-SA/grunt-build-html
tasks/buildHtml-retrieve-remote.js
function (data, fragmentKey, cachePath, callback) { debug(' write content in file system'); var basePath = path.dirname(fragmentKey); if (basePath){ mkdirp.sync(cachePath + '/' + basePath); } fs.writeFile(cachePath + '/' + fragmentKey, data, function (err) { if (err) { callback(err); } else { callback(null, data); } }); }
javascript
function (data, fragmentKey, cachePath, callback) { debug(' write content in file system'); var basePath = path.dirname(fragmentKey); if (basePath){ mkdirp.sync(cachePath + '/' + basePath); } fs.writeFile(cachePath + '/' + fragmentKey, data, function (err) { if (err) { callback(err); } else { callback(null, data); } }); }
[ "function", "(", "data", ",", "fragmentKey", ",", "cachePath", ",", "callback", ")", "{", "debug", "(", "' write content in file system'", ")", ";", "var", "basePath", "=", "path", ".", "dirname", "(", "fragmentKey", ")", ";", "if", "(", "basePath", ")", "{", "mkdirp", ".", "sync", "(", "cachePath", "+", "'/'", "+", "basePath", ")", ";", "}", "fs", ".", "writeFile", "(", "cachePath", "+", "'/'", "+", "fragmentKey", ",", "data", ",", "function", "(", "err", ")", "{", "if", "(", "err", ")", "{", "callback", "(", "err", ")", ";", "}", "else", "{", "callback", "(", "null", ",", "data", ")", ";", "}", "}", ")", ";", "}" ]
Dump remote content in file system @param data Remote content data @param fragmentKey Remote content key @param cachePath Temp FS cache directory @param callback Method to call when file is written
[ "Dump", "remote", "content", "in", "file", "system" ]
6fe1644ff6d08e0eada9482ae9dcdb0d4169ea2e
https://github.com/Smile-SA/grunt-build-html/blob/6fe1644ff6d08e0eada9482ae9dcdb0d4169ea2e/tasks/buildHtml-retrieve-remote.js#L58-L71
44,576
MiguelCastillo/bit-loader
src/plugin/plugin.js
runHandler
function runHandler(plugin, handler, cancel) { return function runHandlerDelegate(data) { if (!data) { return Promise.resolve(); } return Promise .resolve(handler.handler(data, plugin, cancel)) .then(function(result) { return data.configure(result); }); }; }
javascript
function runHandler(plugin, handler, cancel) { return function runHandlerDelegate(data) { if (!data) { return Promise.resolve(); } return Promise .resolve(handler.handler(data, plugin, cancel)) .then(function(result) { return data.configure(result); }); }; }
[ "function", "runHandler", "(", "plugin", ",", "handler", ",", "cancel", ")", "{", "return", "function", "runHandlerDelegate", "(", "data", ")", "{", "if", "(", "!", "data", ")", "{", "return", "Promise", ".", "resolve", "(", ")", ";", "}", "return", "Promise", ".", "resolve", "(", "handler", ".", "handler", "(", "data", ",", "plugin", ",", "cancel", ")", ")", ".", "then", "(", "function", "(", "result", ")", "{", "return", "data", ".", "configure", "(", "result", ")", ";", "}", ")", ";", "}", ";", "}" ]
Method that return a function that executes a plugin handler.
[ "Method", "that", "return", "a", "function", "that", "executes", "a", "plugin", "handler", "." ]
da9d18952d87014fdb09e7a8320a24cbf1c2b436
https://github.com/MiguelCastillo/bit-loader/blob/da9d18952d87014fdb09e7a8320a24cbf1c2b436/src/plugin/plugin.js#L111-L123
44,577
feedhenry/fh-mbaas-client
lib/app/appforms/forms.js
submitFormData
function submitFormData(params, cb) { var resourcePath = config.addURIParams("/appforms/forms/:id/submitFormData", params); var method = "POST"; var data = params.submission; params.resourcePath = resourcePath; params.method = method; params.data = data; mbaasRequest.app(params, cb); }
javascript
function submitFormData(params, cb) { var resourcePath = config.addURIParams("/appforms/forms/:id/submitFormData", params); var method = "POST"; var data = params.submission; params.resourcePath = resourcePath; params.method = method; params.data = data; mbaasRequest.app(params, cb); }
[ "function", "submitFormData", "(", "params", ",", "cb", ")", "{", "var", "resourcePath", "=", "config", ".", "addURIParams", "(", "\"/appforms/forms/:id/submitFormData\"", ",", "params", ")", ";", "var", "method", "=", "\"POST\"", ";", "var", "data", "=", "params", ".", "submission", ";", "params", ".", "resourcePath", "=", "resourcePath", ";", "params", ".", "method", "=", "method", ";", "params", ".", "data", "=", "data", ";", "mbaasRequest", ".", "app", "(", "params", ",", "cb", ")", ";", "}" ]
Making A Submisison Against A Form
[ "Making", "A", "Submisison", "Against", "A", "Form" ]
2d5a9cbb32e1b2464d71ffa18513358fea388859
https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/lib/app/appforms/forms.js#L39-L49
44,578
feedhenry/fh-mbaas-client
lib/app/appforms/forms.js
search
function search(params, cb) { var resourcePath = config.addURIParams("/appforms/forms/search", params); var method = "POST"; var data = params.searchParams; params.resourcePath = resourcePath; params.method = method; params.data = data; mbaasRequest.app(params, cb); }
javascript
function search(params, cb) { var resourcePath = config.addURIParams("/appforms/forms/search", params); var method = "POST"; var data = params.searchParams; params.resourcePath = resourcePath; params.method = method; params.data = data; mbaasRequest.app(params, cb); }
[ "function", "search", "(", "params", ",", "cb", ")", "{", "var", "resourcePath", "=", "config", ".", "addURIParams", "(", "\"/appforms/forms/search\"", ",", "params", ")", ";", "var", "method", "=", "\"POST\"", ";", "var", "data", "=", "params", ".", "searchParams", ";", "params", ".", "resourcePath", "=", "resourcePath", ";", "params", ".", "method", "=", "method", ";", "params", ".", "data", "=", "data", ";", "mbaasRequest", ".", "app", "(", "params", ",", "cb", ")", ";", "}" ]
Search For Forms Based On Ids. This will return fully populated forms @param params @param cb
[ "Search", "For", "Forms", "Based", "On", "Ids", ".", "This", "will", "return", "fully", "populated", "forms" ]
2d5a9cbb32e1b2464d71ffa18513358fea388859
https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/lib/app/appforms/forms.js#L57-L67
44,579
tmorin/ceb
dist/systemjs/helper/functions.js
partial
function partial(fn) { for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { args[_key - 1] = arguments[_key]; } return function () { return fn.apply(this, args.concat(toArray(arguments))); }; }
javascript
function partial(fn) { for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { args[_key - 1] = arguments[_key]; } return function () { return fn.apply(this, args.concat(toArray(arguments))); }; }
[ "function", "partial", "(", "fn", ")", "{", "for", "(", "var", "_len", "=", "arguments", ".", "length", ",", "args", "=", "Array", "(", "_len", ">", "1", "?", "_len", "-", "1", ":", "0", ")", ",", "_key", "=", "1", ";", "_key", "<", "_len", ";", "_key", "++", ")", "{", "args", "[", "_key", "-", "1", "]", "=", "arguments", "[", "_key", "]", ";", "}", "return", "function", "(", ")", "{", "return", "fn", ".", "apply", "(", "this", ",", "args", ".", "concat", "(", "toArray", "(", "arguments", ")", ")", ")", ";", "}", ";", "}" ]
Partially apply a function by filling in any number of its arguments, without changing its dynamic this value. @param {!Function} fn the function to partially apply arguments to @param {...} args the arguments to be partially applied @returns {Function} the new partially applied function
[ "Partially", "apply", "a", "function", "by", "filling", "in", "any", "number", "of", "its", "arguments", "without", "changing", "its", "dynamic", "this", "value", "." ]
7cc0904b482aa99e5123302c5de4401f7a80af02
https://github.com/tmorin/ceb/blob/7cc0904b482aa99e5123302c5de4401f7a80af02/dist/systemjs/helper/functions.js#L15-L23
44,580
harrisiirak/bunyan-redis
index.js
RedisTransport
function RedisTransport (opts) { this._container = opts.container || 'logs'; this._length = opts.length || undefined; this._client = opts.client || redis.createClient(opts.port, opts.host); // Authorize cleint if (opts.hasOwnProperty('password')) { this._client.auth(opts.password); } // Set database index if (opts.hasOwnProperty('db')) { this._client.select(opts.db); } }
javascript
function RedisTransport (opts) { this._container = opts.container || 'logs'; this._length = opts.length || undefined; this._client = opts.client || redis.createClient(opts.port, opts.host); // Authorize cleint if (opts.hasOwnProperty('password')) { this._client.auth(opts.password); } // Set database index if (opts.hasOwnProperty('db')) { this._client.select(opts.db); } }
[ "function", "RedisTransport", "(", "opts", ")", "{", "this", ".", "_container", "=", "opts", ".", "container", "||", "'logs'", ";", "this", ".", "_length", "=", "opts", ".", "length", "||", "undefined", ";", "this", ".", "_client", "=", "opts", ".", "client", "||", "redis", ".", "createClient", "(", "opts", ".", "port", ",", "opts", ".", "host", ")", ";", "// Authorize cleint", "if", "(", "opts", ".", "hasOwnProperty", "(", "'password'", ")", ")", "{", "this", ".", "_client", ".", "auth", "(", "opts", ".", "password", ")", ";", "}", "// Set database index", "if", "(", "opts", ".", "hasOwnProperty", "(", "'db'", ")", ")", "{", "this", ".", "_client", ".", "select", "(", "opts", ".", "db", ")", ";", "}", "}" ]
Create a new RedisTransport instance @param {Object} opts Transport options object @param {String} opts.container Redis key @param {Number} opts.length List max length @param {Object} opts.client Redis client instance @param {String} opts.host Redis host @param {Number} opts.port Redis port @param {Number} opts.db Redis database index @param {String} opts.password Redis password @constructor
[ "Create", "a", "new", "RedisTransport", "instance" ]
d5035e5f2cdee44f20372c15ea181d70aa129fd1
https://github.com/harrisiirak/bunyan-redis/blob/d5035e5f2cdee44f20372c15ea181d70aa129fd1/index.js#L22-L36
44,581
harrisiirak/bunyan-redis
index.js
findListLength
function findListLength (args, next) { client.llen(self._container, function listLengthFound (err, length) { if (err) { return next(err); } args.length = length; return next(null, length); }); }
javascript
function findListLength (args, next) { client.llen(self._container, function listLengthFound (err, length) { if (err) { return next(err); } args.length = length; return next(null, length); }); }
[ "function", "findListLength", "(", "args", ",", "next", ")", "{", "client", ".", "llen", "(", "self", ".", "_container", ",", "function", "listLengthFound", "(", "err", ",", "length", ")", "{", "if", "(", "err", ")", "{", "return", "next", "(", "err", ")", ";", "}", "args", ".", "length", "=", "length", ";", "return", "next", "(", "null", ",", "length", ")", ";", "}", ")", ";", "}" ]
Find list length
[ "Find", "list", "length" ]
d5035e5f2cdee44f20372c15ea181d70aa129fd1
https://github.com/harrisiirak/bunyan-redis/blob/d5035e5f2cdee44f20372c15ea181d70aa129fd1/index.js#L55-L64
44,582
harrisiirak/bunyan-redis
index.js
trimList
function trimList (args, next) { if (self._length === undefined || args.length <= self._length) { return next(); } client.ltrim(self._container, 0, self._length, function dataStored (err) { if (err) { return next(err); } return next(); }); }
javascript
function trimList (args, next) { if (self._length === undefined || args.length <= self._length) { return next(); } client.ltrim(self._container, 0, self._length, function dataStored (err) { if (err) { return next(err); } return next(); }); }
[ "function", "trimList", "(", "args", ",", "next", ")", "{", "if", "(", "self", ".", "_length", "===", "undefined", "||", "args", ".", "length", "<=", "self", ".", "_length", ")", "{", "return", "next", "(", ")", ";", "}", "client", ".", "ltrim", "(", "self", ".", "_container", ",", "0", ",", "self", ".", "_length", ",", "function", "dataStored", "(", "err", ")", "{", "if", "(", "err", ")", "{", "return", "next", "(", "err", ")", ";", "}", "return", "next", "(", ")", ";", "}", ")", ";", "}" ]
Trim data list
[ "Trim", "data", "list" ]
d5035e5f2cdee44f20372c15ea181d70aa129fd1
https://github.com/harrisiirak/bunyan-redis/blob/d5035e5f2cdee44f20372c15ea181d70aa129fd1/index.js#L79-L91
44,583
theboyWhoCriedWoolf/transition-manager
src/core/fsm.js
_transitionTo
function _transitionTo( nextState, action, data ) { _cancelled = false; _transitionCompleted = false; if( isCancelled() ) { return false; } if( _currentState ) { let previousState = _currentState; if(_options.history){ _history.push(previousState.name); } } _currentState = nextState; if( action ) { _stateChangedHandler( action, data ); } else { _transitionCompleted = true; FSM.log('State transition Completed! Current State :: ' + _currentState.name ); stateChanged.dispatch(_currentState); } }
javascript
function _transitionTo( nextState, action, data ) { _cancelled = false; _transitionCompleted = false; if( isCancelled() ) { return false; } if( _currentState ) { let previousState = _currentState; if(_options.history){ _history.push(previousState.name); } } _currentState = nextState; if( action ) { _stateChangedHandler( action, data ); } else { _transitionCompleted = true; FSM.log('State transition Completed! Current State :: ' + _currentState.name ); stateChanged.dispatch(_currentState); } }
[ "function", "_transitionTo", "(", "nextState", ",", "action", ",", "data", ")", "{", "_cancelled", "=", "false", ";", "_transitionCompleted", "=", "false", ";", "if", "(", "isCancelled", "(", ")", ")", "{", "return", "false", ";", "}", "if", "(", "_currentState", ")", "{", "let", "previousState", "=", "_currentState", ";", "if", "(", "_options", ".", "history", ")", "{", "_history", ".", "push", "(", "previousState", ".", "name", ")", ";", "}", "}", "_currentState", "=", "nextState", ";", "if", "(", "action", ")", "{", "_stateChangedHandler", "(", "action", ",", "data", ")", ";", "}", "else", "{", "_transitionCompleted", "=", "true", ";", "FSM", ".", "log", "(", "'State transition Completed! Current State :: '", "+", "_currentState", ".", "name", ")", ";", "stateChanged", ".", "dispatch", "(", "_currentState", ")", ";", "}", "}" ]
transition to the next state @param {object} nextState new state object @param {string} action actionID @param {object} data data sent with the action @param {string} actionIdentifier state and action combined to make a unique string
[ "transition", "to", "the", "next", "state" ]
a20fda0bb07c0098bf709ea03770b1ee2a855655
https://github.com/theboyWhoCriedWoolf/transition-manager/blob/a20fda0bb07c0098bf709ea03770b1ee2a855655/src/core/fsm.js#L52-L73
44,584
theboyWhoCriedWoolf/transition-manager
src/core/fsm.js
_processActionQueue
function _processActionQueue() { if( _actionQueue.length > 0 ) { var stateEvent = _actionQueue.shift(); if(!_currentState.getTarget(stateEvent.action)) { _processActionQueue(); } else { } FSM.action( stateEvent.action, stateEvent.data ); return false; } FSM.log('State transition Completed! Current State :: ' + _currentState.name ); stateChanged.dispatch(_currentState); }
javascript
function _processActionQueue() { if( _actionQueue.length > 0 ) { var stateEvent = _actionQueue.shift(); if(!_currentState.getTarget(stateEvent.action)) { _processActionQueue(); } else { } FSM.action( stateEvent.action, stateEvent.data ); return false; } FSM.log('State transition Completed! Current State :: ' + _currentState.name ); stateChanged.dispatch(_currentState); }
[ "function", "_processActionQueue", "(", ")", "{", "if", "(", "_actionQueue", ".", "length", ">", "0", ")", "{", "var", "stateEvent", "=", "_actionQueue", ".", "shift", "(", ")", ";", "if", "(", "!", "_currentState", ".", "getTarget", "(", "stateEvent", ".", "action", ")", ")", "{", "_processActionQueue", "(", ")", ";", "}", "else", "{", "}", "FSM", ".", "action", "(", "stateEvent", ".", "action", ",", "stateEvent", ".", "data", ")", ";", "return", "false", ";", "}", "FSM", ".", "log", "(", "'State transition Completed! Current State :: '", "+", "_currentState", ".", "name", ")", ";", "stateChanged", ".", "dispatch", "(", "_currentState", ")", ";", "}" ]
If states have queued up loop through and action all states in the queue until none remain
[ "If", "states", "have", "queued", "up", "loop", "through", "and", "action", "all", "states", "in", "the", "queue", "until", "none", "remain" ]
a20fda0bb07c0098bf709ea03770b1ee2a855655
https://github.com/theboyWhoCriedWoolf/transition-manager/blob/a20fda0bb07c0098bf709ea03770b1ee2a855655/src/core/fsm.js#L80-L96
44,585
theboyWhoCriedWoolf/transition-manager
src/core/fsm.js
function( action, target, actionIdnentifier ) { if( this._transitions[ action ] ) { return false; } this._transitions[ action ] = { target : target, _id : actionIdnentifier }; }
javascript
function( action, target, actionIdnentifier ) { if( this._transitions[ action ] ) { return false; } this._transitions[ action ] = { target : target, _id : actionIdnentifier }; }
[ "function", "(", "action", ",", "target", ",", "actionIdnentifier", ")", "{", "if", "(", "this", ".", "_transitions", "[", "action", "]", ")", "{", "return", "false", ";", "}", "this", ".", "_transitions", "[", "action", "]", "=", "{", "target", ":", "target", ",", "_id", ":", "actionIdnentifier", "}", ";", "}" ]
add the available trasitions for each state @param {string} action e.g.'GOTOHOME' @param {string} target e.g. 'HOME'
[ "add", "the", "available", "trasitions", "for", "each", "state" ]
a20fda0bb07c0098bf709ea03770b1ee2a855655
https://github.com/theboyWhoCriedWoolf/transition-manager/blob/a20fda0bb07c0098bf709ea03770b1ee2a855655/src/core/fsm.js#L268-L271
44,586
codemix/modeling
lib/factory.js
function (Class, descriptors, staticDescriptors) { var castAll = Casting.forDescriptors(descriptors); function cast (value) { if (!(value instanceof this)) { return new this(castAll(value)); } else { return castAll(value); } } cast.isAutoGenerated = true; return cast; }
javascript
function (Class, descriptors, staticDescriptors) { var castAll = Casting.forDescriptors(descriptors); function cast (value) { if (!(value instanceof this)) { return new this(castAll(value)); } else { return castAll(value); } } cast.isAutoGenerated = true; return cast; }
[ "function", "(", "Class", ",", "descriptors", ",", "staticDescriptors", ")", "{", "var", "castAll", "=", "Casting", ".", "forDescriptors", "(", "descriptors", ")", ";", "function", "cast", "(", "value", ")", "{", "if", "(", "!", "(", "value", "instanceof", "this", ")", ")", "{", "return", "new", "this", "(", "castAll", "(", "value", ")", ")", ";", "}", "else", "{", "return", "castAll", "(", "value", ")", ";", "}", "}", "cast", ".", "isAutoGenerated", "=", "true", ";", "return", "cast", ";", "}" ]
Create a function which can cast objects to this class. @param {Function} Class The class. @param {Object} descriptors The property descriptors. @param {Object} staticDescriptors The static property descriptors. @return {Function} The generated function.
[ "Create", "a", "function", "which", "can", "cast", "objects", "to", "this", "class", "." ]
7c95e2bae2e5ea12565a567a55535fe4d63c513c
https://github.com/codemix/modeling/blob/7c95e2bae2e5ea12565a567a55535fe4d63c513c/lib/factory.js#L75-L88
44,587
codemix/modeling
lib/factory.js
function (Class, descriptors, staticDescriptors) { var validate = Validating.forDescriptors(descriptors); validate.isAutoGenerated = true; return validate; }
javascript
function (Class, descriptors, staticDescriptors) { var validate = Validating.forDescriptors(descriptors); validate.isAutoGenerated = true; return validate; }
[ "function", "(", "Class", ",", "descriptors", ",", "staticDescriptors", ")", "{", "var", "validate", "=", "Validating", ".", "forDescriptors", "(", "descriptors", ")", ";", "validate", ".", "isAutoGenerated", "=", "true", ";", "return", "validate", ";", "}" ]
Create a function which can validate instances of the class. @param {Function} Class The class. @param {Object} descriptors The property descriptors. @param {Object} staticDescriptors The static property descriptors. @return {Function} The generated function.
[ "Create", "a", "function", "which", "can", "validate", "instances", "of", "the", "class", "." ]
7c95e2bae2e5ea12565a567a55535fe4d63c513c
https://github.com/codemix/modeling/blob/7c95e2bae2e5ea12565a567a55535fe4d63c513c/lib/factory.js#L98-L102
44,588
codemix/modeling
lib/factory.js
function (Class, descriptors, staticDescriptors) { var casters = {}, validators = {}, body = '"use strict";\n\ var valid = true,\n\ errors = {},\n\ result;\n\ if (values === undefined) {\n\ values = subject || {};\n\ subject = new this();\n\ }\n'; each(descriptors, function (descriptor, key) { if (key === '[[state]]' || key === 'initialize' || (!descriptor.writable && typeof descriptor.set !== 'function') || typeof descriptor.value === 'function' ) { return; } var accessor = createAccessor(key); body += 'if (values'+accessor+' !== undefined) {\n'; if (descriptor.type) { casters[key] = Casting.get(descriptor.type); body += 'if (values'+accessor+' === null) {\n\ subject'+accessor+' = null;\n\ }\n\ else {\n\ result = tryCatch(casters'+accessor+', values'+accessor+');\n\ if (result.error) {\n\ valid = false;\n\ errors'+accessor+' = result.error.message;\n\ }\n\ else {\n\ subject'+accessor+' = result.value;\n\ }\n\ }\n'; } else { body += 'subject'+accessor+' = values'+accessor+';\n'; } body += '}\n'; if (descriptor.rules) { validators[key] = Validating.forDescriptor(key, descriptor); body += 'if (!errors'+accessor+') {\n\ result = validators'+accessor+'(subject'+accessor+');\n\ if (!result.valid) {\n\ valid = false;\n\ errors'+accessor+' = result.error;\n\ }\n\ }\n'; } }); body += 'return {\n\ valid: valid,\n\ value: subject,\n\ errors: errors\n\ };'; var input = this.createDynamicFunction('validators', 'casters', 'tryCatch', 'subject', 'values', body); var fn = function (subject, values) { return input.call(this, validators, casters, tryCatch1, subject, values); }; fn.isAutoGenerated = true; return fn; }
javascript
function (Class, descriptors, staticDescriptors) { var casters = {}, validators = {}, body = '"use strict";\n\ var valid = true,\n\ errors = {},\n\ result;\n\ if (values === undefined) {\n\ values = subject || {};\n\ subject = new this();\n\ }\n'; each(descriptors, function (descriptor, key) { if (key === '[[state]]' || key === 'initialize' || (!descriptor.writable && typeof descriptor.set !== 'function') || typeof descriptor.value === 'function' ) { return; } var accessor = createAccessor(key); body += 'if (values'+accessor+' !== undefined) {\n'; if (descriptor.type) { casters[key] = Casting.get(descriptor.type); body += 'if (values'+accessor+' === null) {\n\ subject'+accessor+' = null;\n\ }\n\ else {\n\ result = tryCatch(casters'+accessor+', values'+accessor+');\n\ if (result.error) {\n\ valid = false;\n\ errors'+accessor+' = result.error.message;\n\ }\n\ else {\n\ subject'+accessor+' = result.value;\n\ }\n\ }\n'; } else { body += 'subject'+accessor+' = values'+accessor+';\n'; } body += '}\n'; if (descriptor.rules) { validators[key] = Validating.forDescriptor(key, descriptor); body += 'if (!errors'+accessor+') {\n\ result = validators'+accessor+'(subject'+accessor+');\n\ if (!result.valid) {\n\ valid = false;\n\ errors'+accessor+' = result.error;\n\ }\n\ }\n'; } }); body += 'return {\n\ valid: valid,\n\ value: subject,\n\ errors: errors\n\ };'; var input = this.createDynamicFunction('validators', 'casters', 'tryCatch', 'subject', 'values', body); var fn = function (subject, values) { return input.call(this, validators, casters, tryCatch1, subject, values); }; fn.isAutoGenerated = true; return fn; }
[ "function", "(", "Class", ",", "descriptors", ",", "staticDescriptors", ")", "{", "var", "casters", "=", "{", "}", ",", "validators", "=", "{", "}", ",", "body", "=", "'\"use strict\";\\n\\\n var valid = true,\\n\\\n errors = {},\\n\\\n result;\\n\\\n if (values === undefined) {\\n\\\n values = subject || {};\\n\\\n subject = new this();\\n\\\n }\\n'", ";", "each", "(", "descriptors", ",", "function", "(", "descriptor", ",", "key", ")", "{", "if", "(", "key", "===", "'[[state]]'", "||", "key", "===", "'initialize'", "||", "(", "!", "descriptor", ".", "writable", "&&", "typeof", "descriptor", ".", "set", "!==", "'function'", ")", "||", "typeof", "descriptor", ".", "value", "===", "'function'", ")", "{", "return", ";", "}", "var", "accessor", "=", "createAccessor", "(", "key", ")", ";", "body", "+=", "'if (values'", "+", "accessor", "+", "' !== undefined) {\\n'", ";", "if", "(", "descriptor", ".", "type", ")", "{", "casters", "[", "key", "]", "=", "Casting", ".", "get", "(", "descriptor", ".", "type", ")", ";", "body", "+=", "'if (values'", "+", "accessor", "+", "' === null) {\\n\\\n subject'", "+", "accessor", "+", "' = null;\\n\\\n }\\n\\\n else {\\n\\\n result = tryCatch(casters'", "+", "accessor", "+", "', values'", "+", "accessor", "+", "');\\n\\\n if (result.error) {\\n\\\n valid = false;\\n\\\n errors'", "+", "accessor", "+", "' = result.error.message;\\n\\\n }\\n\\\n else {\\n\\\n subject'", "+", "accessor", "+", "' = result.value;\\n\\\n }\\n\\\n }\\n'", ";", "}", "else", "{", "body", "+=", "'subject'", "+", "accessor", "+", "' = values'", "+", "accessor", "+", "';\\n'", ";", "}", "body", "+=", "'}\\n'", ";", "if", "(", "descriptor", ".", "rules", ")", "{", "validators", "[", "key", "]", "=", "Validating", ".", "forDescriptor", "(", "key", ",", "descriptor", ")", ";", "body", "+=", "'if (!errors'", "+", "accessor", "+", "') {\\n\\\n result = validators'", "+", "accessor", "+", "'(subject'", "+", "accessor", "+", "');\\n\\\n if (!result.valid) {\\n\\\n valid = false;\\n\\\n errors'", "+", "accessor", "+", "' = result.error;\\n\\\n }\\n\\\n }\\n'", ";", "}", "}", ")", ";", "body", "+=", "'return {\\n\\\n valid: valid,\\n\\\n value: subject,\\n\\\n errors: errors\\n\\\n };'", ";", "var", "input", "=", "this", ".", "createDynamicFunction", "(", "'validators'", ",", "'casters'", ",", "'tryCatch'", ",", "'subject'", ",", "'values'", ",", "body", ")", ";", "var", "fn", "=", "function", "(", "subject", ",", "values", ")", "{", "return", "input", ".", "call", "(", "this", ",", "validators", ",", "casters", ",", "tryCatch1", ",", "subject", ",", "values", ")", ";", "}", ";", "fn", ".", "isAutoGenerated", "=", "true", ";", "return", "fn", ";", "}" ]
Create a function which can accept user input for the model. @param {Function} Class The class. @param {Object} descriptors The property descriptors. @param {Object} staticDescriptors The static property descriptors. @return {Function} The generated function.
[ "Create", "a", "function", "which", "can", "accept", "user", "input", "for", "the", "model", "." ]
7c95e2bae2e5ea12565a567a55535fe4d63c513c
https://github.com/codemix/modeling/blob/7c95e2bae2e5ea12565a567a55535fe4d63c513c/lib/factory.js#L112-L180
44,589
codemix/modeling
lib/factory.js
function (Class, descriptors) { var body = '"use strict";\n'; var casters = {}; each(descriptors, function (descriptor, name) { if (descriptor.writable || typeof descriptor.set === 'function') { var accessor = createAccessor(name); if (descriptor.cast || descriptor.type) { casters[name] = Casting.forDescriptor(descriptor); body += 'if (config' + accessor + ' !== undefined) {\n\ this' + accessor + ' = casters' + accessor + '(config' + accessor + ');\n\ }\n'; } else { body += 'if (config' + accessor + ' !== undefined) {\n\ this' + accessor + ' = config' + accessor + ';\n\ }\n'; } } }); var configure = this.createDynamicFunction('casters', 'config', body); var fn = function (config) { return configure.call(this, casters, config); }; fn.isAutoGenerated = true; return fn; }
javascript
function (Class, descriptors) { var body = '"use strict";\n'; var casters = {}; each(descriptors, function (descriptor, name) { if (descriptor.writable || typeof descriptor.set === 'function') { var accessor = createAccessor(name); if (descriptor.cast || descriptor.type) { casters[name] = Casting.forDescriptor(descriptor); body += 'if (config' + accessor + ' !== undefined) {\n\ this' + accessor + ' = casters' + accessor + '(config' + accessor + ');\n\ }\n'; } else { body += 'if (config' + accessor + ' !== undefined) {\n\ this' + accessor + ' = config' + accessor + ';\n\ }\n'; } } }); var configure = this.createDynamicFunction('casters', 'config', body); var fn = function (config) { return configure.call(this, casters, config); }; fn.isAutoGenerated = true; return fn; }
[ "function", "(", "Class", ",", "descriptors", ")", "{", "var", "body", "=", "'\"use strict\";\\n'", ";", "var", "casters", "=", "{", "}", ";", "each", "(", "descriptors", ",", "function", "(", "descriptor", ",", "name", ")", "{", "if", "(", "descriptor", ".", "writable", "||", "typeof", "descriptor", ".", "set", "===", "'function'", ")", "{", "var", "accessor", "=", "createAccessor", "(", "name", ")", ";", "if", "(", "descriptor", ".", "cast", "||", "descriptor", ".", "type", ")", "{", "casters", "[", "name", "]", "=", "Casting", ".", "forDescriptor", "(", "descriptor", ")", ";", "body", "+=", "'if (config'", "+", "accessor", "+", "' !== undefined) {\\n\\\n this'", "+", "accessor", "+", "' = casters'", "+", "accessor", "+", "'(config'", "+", "accessor", "+", "');\\n\\\n }\\n'", ";", "}", "else", "{", "body", "+=", "'if (config'", "+", "accessor", "+", "' !== undefined) {\\n\\\n this'", "+", "accessor", "+", "' = config'", "+", "accessor", "+", "';\\n\\\n }\\n'", ";", "}", "}", "}", ")", ";", "var", "configure", "=", "this", ".", "createDynamicFunction", "(", "'casters'", ",", "'config'", ",", "body", ")", ";", "var", "fn", "=", "function", "(", "config", ")", "{", "return", "configure", ".", "call", "(", "this", ",", "casters", ",", "config", ")", ";", "}", ";", "fn", ".", "isAutoGenerated", "=", "true", ";", "return", "fn", ";", "}" ]
Create a `configure` function for a class. @param {Function} Class The class. @param {Object} descriptors The property descriptors. @return {Function} The configure function.
[ "Create", "a", "configure", "function", "for", "a", "class", "." ]
7c95e2bae2e5ea12565a567a55535fe4d63c513c
https://github.com/codemix/modeling/blob/7c95e2bae2e5ea12565a567a55535fe4d63c513c/lib/factory.js#L189-L214
44,590
codemix/modeling
lib/factory.js
function (Class, descriptors) { ClassFactory.prototype.updateDynamicFunctions.call(this, Class, descriptors); if (!Class.cast || Class.cast.isAutoGenerated) { Class.cast = this.createStaticCast(Class, descriptors); } if (!Class.validate || Class.validate.isAutoGenerated) { Class.validate = this.createStaticValidate(Class, descriptors); } if (!Class.input || Class.input.isAutoGenerated) { Class.input = this.createStaticInput(Class, descriptors); } if (!Class.toJSON || Class.toJSON.isAutoGenerated) { Class.toJSON = this.createStaticToJSON(Class, descriptors); } }
javascript
function (Class, descriptors) { ClassFactory.prototype.updateDynamicFunctions.call(this, Class, descriptors); if (!Class.cast || Class.cast.isAutoGenerated) { Class.cast = this.createStaticCast(Class, descriptors); } if (!Class.validate || Class.validate.isAutoGenerated) { Class.validate = this.createStaticValidate(Class, descriptors); } if (!Class.input || Class.input.isAutoGenerated) { Class.input = this.createStaticInput(Class, descriptors); } if (!Class.toJSON || Class.toJSON.isAutoGenerated) { Class.toJSON = this.createStaticToJSON(Class, descriptors); } }
[ "function", "(", "Class", ",", "descriptors", ")", "{", "ClassFactory", ".", "prototype", ".", "updateDynamicFunctions", ".", "call", "(", "this", ",", "Class", ",", "descriptors", ")", ";", "if", "(", "!", "Class", ".", "cast", "||", "Class", ".", "cast", ".", "isAutoGenerated", ")", "{", "Class", ".", "cast", "=", "this", ".", "createStaticCast", "(", "Class", ",", "descriptors", ")", ";", "}", "if", "(", "!", "Class", ".", "validate", "||", "Class", ".", "validate", ".", "isAutoGenerated", ")", "{", "Class", ".", "validate", "=", "this", ".", "createStaticValidate", "(", "Class", ",", "descriptors", ")", ";", "}", "if", "(", "!", "Class", ".", "input", "||", "Class", ".", "input", ".", "isAutoGenerated", ")", "{", "Class", ".", "input", "=", "this", ".", "createStaticInput", "(", "Class", ",", "descriptors", ")", ";", "}", "if", "(", "!", "Class", ".", "toJSON", "||", "Class", ".", "toJSON", ".", "isAutoGenerated", ")", "{", "Class", ".", "toJSON", "=", "this", ".", "createStaticToJSON", "(", "Class", ",", "descriptors", ")", ";", "}", "}" ]
Update the dynamic auto-generated functions for a class. @param {Function} Class The class. @param {Object} descriptors The property descriptors. @param {Object} staticDescriptors The static property descriptors.
[ "Update", "the", "dynamic", "auto", "-", "generated", "functions", "for", "a", "class", "." ]
7c95e2bae2e5ea12565a567a55535fe4d63c513c
https://github.com/codemix/modeling/blob/7c95e2bae2e5ea12565a567a55535fe4d63c513c/lib/factory.js#L270-L284
44,591
codemix/modeling
lib/factory.js
tryCatch1
function tryCatch1 (fn, arg1) { var errorObject = {}; try { errorObject.value = fn(arg1); } catch (e) { errorObject.error = e; } return errorObject; }
javascript
function tryCatch1 (fn, arg1) { var errorObject = {}; try { errorObject.value = fn(arg1); } catch (e) { errorObject.error = e; } return errorObject; }
[ "function", "tryCatch1", "(", "fn", ",", "arg1", ")", "{", "var", "errorObject", "=", "{", "}", ";", "try", "{", "errorObject", ".", "value", "=", "fn", "(", "arg1", ")", ";", "}", "catch", "(", "e", ")", "{", "errorObject", ".", "error", "=", "e", ";", "}", "return", "errorObject", ";", "}" ]
try..catch causes deoptimisation in V8 and most other JS engines. Using a specialist function minimises the impact.
[ "try", "..", "catch", "causes", "deoptimisation", "in", "V8", "and", "most", "other", "JS", "engines", ".", "Using", "a", "specialist", "function", "minimises", "the", "impact", "." ]
7c95e2bae2e5ea12565a567a55535fe4d63c513c
https://github.com/codemix/modeling/blob/7c95e2bae2e5ea12565a567a55535fe4d63c513c/lib/factory.js#L290-L299
44,592
janschaefer/GivenJS
given-core/lib/model/model.js
SuiteModel
function SuiteModel (name) { this.className = 'js.' + name this.scenarios = [] this.tagMap = {} this.tagMap.JS = new TagModel('JS') log('Creating new model ' + this.className) }
javascript
function SuiteModel (name) { this.className = 'js.' + name this.scenarios = [] this.tagMap = {} this.tagMap.JS = new TagModel('JS') log('Creating new model ' + this.className) }
[ "function", "SuiteModel", "(", "name", ")", "{", "this", ".", "className", "=", "'js.'", "+", "name", "this", ".", "scenarios", "=", "[", "]", "this", ".", "tagMap", "=", "{", "}", "this", ".", "tagMap", ".", "JS", "=", "new", "TagModel", "(", "'JS'", ")", "log", "(", "'Creating new model '", "+", "this", ".", "className", ")", "}" ]
A SuiteModel represents a collection of ScenarioModels @param name @see ScenarioModel @constructor
[ "A", "SuiteModel", "represents", "a", "collection", "of", "ScenarioModels" ]
743c2773c00ad0822c65d2b7a5f337d3ee582538
https://github.com/janschaefer/GivenJS/blob/743c2773c00ad0822c65d2b7a5f337d3ee582538/given-core/lib/model/model.js#L162-L169
44,593
mchalapuk/hyper-text-slider
lib/core/slider.js
Slider
function Slider(elem) { check(elem, 'elem').is.anInstanceOf(Element)(); var priv = {}; priv.elem = elem; priv.transitions = []; priv.phaser = phaser(elem); priv.slides = []; priv.upgrader = upgrader(elem); priv.listeners = {}; priv.tempClasses = []; priv.fromIndex = 1; priv.toIndex = 0; priv.started = false; var pub = {}; /** * Array containing all slide elements. * * @type Array * @access read-only * * @fqn Slider.prototype.slides */ pub.slides = priv.slides; /** * Index of currently active slide. * * Set to `null` if ${link Slider.prototype.start} was not called on this slider. * * @type Number * @access read-write * * @fqn Slider.prototype.currentIndex */ pub.currentIndex = null; Object.defineProperty(pub, 'currentIndex', { get: function() { return priv.slides.length !== 0? priv.toIndex: null; }, set: partial(moveTo, priv), }); /** * Currently active slide element. * * Set to `null` if ${link Slider.prototype.start} was not called on this slider. * * @type Element * @access read-write * * @fqn Slider.prototype.currentSlide */ pub.currentSlide = null; Object.defineProperty(pub, 'currentSlide', { get: function() { return priv.slides.length !== 0? priv.slides[priv.toIndex]: null; }, set: function() { throw new Error('read only property! please use currentIndex instead'); }, }); bindMethods(pub, [ start, moveTo, moveToNext, moveToPrevious, on, removeListener, ], priv); priv.pub = pub; return pub; }
javascript
function Slider(elem) { check(elem, 'elem').is.anInstanceOf(Element)(); var priv = {}; priv.elem = elem; priv.transitions = []; priv.phaser = phaser(elem); priv.slides = []; priv.upgrader = upgrader(elem); priv.listeners = {}; priv.tempClasses = []; priv.fromIndex = 1; priv.toIndex = 0; priv.started = false; var pub = {}; /** * Array containing all slide elements. * * @type Array * @access read-only * * @fqn Slider.prototype.slides */ pub.slides = priv.slides; /** * Index of currently active slide. * * Set to `null` if ${link Slider.prototype.start} was not called on this slider. * * @type Number * @access read-write * * @fqn Slider.prototype.currentIndex */ pub.currentIndex = null; Object.defineProperty(pub, 'currentIndex', { get: function() { return priv.slides.length !== 0? priv.toIndex: null; }, set: partial(moveTo, priv), }); /** * Currently active slide element. * * Set to `null` if ${link Slider.prototype.start} was not called on this slider. * * @type Element * @access read-write * * @fqn Slider.prototype.currentSlide */ pub.currentSlide = null; Object.defineProperty(pub, 'currentSlide', { get: function() { return priv.slides.length !== 0? priv.slides[priv.toIndex]: null; }, set: function() { throw new Error('read only property! please use currentIndex instead'); }, }); bindMethods(pub, [ start, moveTo, moveToNext, moveToPrevious, on, removeListener, ], priv); priv.pub = pub; return pub; }
[ "function", "Slider", "(", "elem", ")", "{", "check", "(", "elem", ",", "'elem'", ")", ".", "is", ".", "anInstanceOf", "(", "Element", ")", "(", ")", ";", "var", "priv", "=", "{", "}", ";", "priv", ".", "elem", "=", "elem", ";", "priv", ".", "transitions", "=", "[", "]", ";", "priv", ".", "phaser", "=", "phaser", "(", "elem", ")", ";", "priv", ".", "slides", "=", "[", "]", ";", "priv", ".", "upgrader", "=", "upgrader", "(", "elem", ")", ";", "priv", ".", "listeners", "=", "{", "}", ";", "priv", ".", "tempClasses", "=", "[", "]", ";", "priv", ".", "fromIndex", "=", "1", ";", "priv", ".", "toIndex", "=", "0", ";", "priv", ".", "started", "=", "false", ";", "var", "pub", "=", "{", "}", ";", "/**\n * Array containing all slide elements.\n *\n * @type Array\n * @access read-only\n *\n * @fqn Slider.prototype.slides\n */", "pub", ".", "slides", "=", "priv", ".", "slides", ";", "/**\n * Index of currently active slide.\n *\n * Set to `null` if ${link Slider.prototype.start} was not called on this slider.\n *\n * @type Number\n * @access read-write\n *\n * @fqn Slider.prototype.currentIndex\n */", "pub", ".", "currentIndex", "=", "null", ";", "Object", ".", "defineProperty", "(", "pub", ",", "'currentIndex'", ",", "{", "get", ":", "function", "(", ")", "{", "return", "priv", ".", "slides", ".", "length", "!==", "0", "?", "priv", ".", "toIndex", ":", "null", ";", "}", ",", "set", ":", "partial", "(", "moveTo", ",", "priv", ")", ",", "}", ")", ";", "/**\n * Currently active slide element.\n *\n * Set to `null` if ${link Slider.prototype.start} was not called on this slider.\n *\n * @type Element\n * @access read-write\n *\n * @fqn Slider.prototype.currentSlide\n */", "pub", ".", "currentSlide", "=", "null", ";", "Object", ".", "defineProperty", "(", "pub", ",", "'currentSlide'", ",", "{", "get", ":", "function", "(", ")", "{", "return", "priv", ".", "slides", ".", "length", "!==", "0", "?", "priv", ".", "slides", "[", "priv", ".", "toIndex", "]", ":", "null", ";", "}", ",", "set", ":", "function", "(", ")", "{", "throw", "new", "Error", "(", "'read only property! please use currentIndex instead'", ")", ";", "}", ",", "}", ")", ";", "bindMethods", "(", "pub", ",", "[", "start", ",", "moveTo", ",", "moveToNext", ",", "moveToPrevious", ",", "on", ",", "removeListener", ",", "]", ",", "priv", ")", ";", "priv", ".", "pub", "=", "pub", ";", "return", "pub", ";", "}" ]
public Constructs the slider. @param {Element} elem DOM element for the slider @fqn Slider.prototype.constructor
[ "public", "Constructs", "the", "slider", "." ]
2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4
https://github.com/mchalapuk/hyper-text-slider/blob/2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4/lib/core/slider.js#L69-L139
44,594
mchalapuk/hyper-text-slider
lib/core/slider.js
start
function start(priv, callback) { check(priv.started, 'slider.started').is.False(); check(callback, 'callback').is.aFunction.or.Undefined(); priv.startCallback = callback || noop; window.addEventListener('keydown', partial(keyBasedMove, priv), false); priv.elem.addEventListener('click', partial(clickBasedMove, priv), false); priv.upgrader.onSlideUpgraded = acceptSlide.bind(null, priv); priv.upgrader.start(); priv.phaser.addPhaseListener(partial(onPhaseChange, priv)); on(priv, 'slideChange', changeDot.bind(null, priv)); priv.started = true; }
javascript
function start(priv, callback) { check(priv.started, 'slider.started').is.False(); check(callback, 'callback').is.aFunction.or.Undefined(); priv.startCallback = callback || noop; window.addEventListener('keydown', partial(keyBasedMove, priv), false); priv.elem.addEventListener('click', partial(clickBasedMove, priv), false); priv.upgrader.onSlideUpgraded = acceptSlide.bind(null, priv); priv.upgrader.start(); priv.phaser.addPhaseListener(partial(onPhaseChange, priv)); on(priv, 'slideChange', changeDot.bind(null, priv)); priv.started = true; }
[ "function", "start", "(", "priv", ",", "callback", ")", "{", "check", "(", "priv", ".", "started", ",", "'slider.started'", ")", ".", "is", ".", "False", "(", ")", ";", "check", "(", "callback", ",", "'callback'", ")", ".", "is", ".", "aFunction", ".", "or", ".", "Undefined", "(", ")", ";", "priv", ".", "startCallback", "=", "callback", "||", "noop", ";", "window", ".", "addEventListener", "(", "'keydown'", ",", "partial", "(", "keyBasedMove", ",", "priv", ")", ",", "false", ")", ";", "priv", ".", "elem", ".", "addEventListener", "(", "'click'", ",", "partial", "(", "clickBasedMove", ",", "priv", ")", ",", "false", ")", ";", "priv", ".", "upgrader", ".", "onSlideUpgraded", "=", "acceptSlide", ".", "bind", "(", "null", ",", "priv", ")", ";", "priv", ".", "upgrader", ".", "start", "(", ")", ";", "priv", ".", "phaser", ".", "addPhaseListener", "(", "partial", "(", "onPhaseChange", ",", "priv", ")", ")", ";", "on", "(", "priv", ",", "'slideChange'", ",", "changeDot", ".", "bind", "(", "null", ",", "priv", ")", ")", ";", "priv", ".", "started", "=", "true", ";", "}" ]
Upgrades DOM elements and shows the first slide. Starting procedure involves manipuilating DOM and waiting for changes to be visible on the screen, therefore slider will not be started immediately after returning from this call. After all slides are upgraded and visible on the screen, given **callback** will be called by the slider. At that time it's safe to use all features of the slider. ```js slider.start(function() { slider.currentIndex = 1; }); ``` @param {Function} callback that will be called after all slides are upgraded @precondition ${link Slider.prototype.start} was not called on this slider @postcondition calling ${link Slider.prototype.start} again will throw exception @see ${link Common.AUTOBOOT} @fqn Slider.prototype.start
[ "Upgrades", "DOM", "elements", "and", "shows", "the", "first", "slide", "." ]
2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4
https://github.com/mchalapuk/hyper-text-slider/blob/2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4/lib/core/slider.js#L162-L177
44,595
mchalapuk/hyper-text-slider
lib/core/slider.js
moveToPrevious
function moveToPrevious(priv) { moveTo(priv, (priv.toIndex - 1 + priv.slides.length) % priv.slides.length); }
javascript
function moveToPrevious(priv) { moveTo(priv, (priv.toIndex - 1 + priv.slides.length) % priv.slides.length); }
[ "function", "moveToPrevious", "(", "priv", ")", "{", "moveTo", "(", "priv", ",", "(", "priv", ".", "toIndex", "-", "1", "+", "priv", ".", "slides", ".", "length", ")", "%", "priv", ".", "slides", ".", "length", ")", ";", "}" ]
Moves slider previous slide. @precondition ${link Slider.prototype.start} was called on this slider @fqn Slider.prototype.moveToPrevious
[ "Moves", "slider", "previous", "slide", "." ]
2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4
https://github.com/mchalapuk/hyper-text-slider/blob/2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4/lib/core/slider.js#L198-L200
44,596
mchalapuk/hyper-text-slider
lib/core/slider.js
moveTo
function moveTo(priv, index) { check(priv.started, 'slider.started').is.True(); check(index, 'index').is.inRange(0, priv.slides.length)(); var toIndex = index <= priv.slides.length? index % priv.slides.length: index; if (priv.toIndex === toIndex) { return; } removeTempClasses(priv); removeMarkers(priv); priv.fromIndex = priv.toIndex; priv.toIndex = toIndex; addMarkers(priv); addTempClasses(priv); priv.phaser.startTransition(); emitEvent(priv, slidechange(priv.fromIndex, priv.toIndex)); }
javascript
function moveTo(priv, index) { check(priv.started, 'slider.started').is.True(); check(index, 'index').is.inRange(0, priv.slides.length)(); var toIndex = index <= priv.slides.length? index % priv.slides.length: index; if (priv.toIndex === toIndex) { return; } removeTempClasses(priv); removeMarkers(priv); priv.fromIndex = priv.toIndex; priv.toIndex = toIndex; addMarkers(priv); addTempClasses(priv); priv.phaser.startTransition(); emitEvent(priv, slidechange(priv.fromIndex, priv.toIndex)); }
[ "function", "moveTo", "(", "priv", ",", "index", ")", "{", "check", "(", "priv", ".", "started", ",", "'slider.started'", ")", ".", "is", ".", "True", "(", ")", ";", "check", "(", "index", ",", "'index'", ")", ".", "is", ".", "inRange", "(", "0", ",", "priv", ".", "slides", ".", "length", ")", "(", ")", ";", "var", "toIndex", "=", "index", "<=", "priv", ".", "slides", ".", "length", "?", "index", "%", "priv", ".", "slides", ".", "length", ":", "index", ";", "if", "(", "priv", ".", "toIndex", "===", "toIndex", ")", "{", "return", ";", "}", "removeTempClasses", "(", "priv", ")", ";", "removeMarkers", "(", "priv", ")", ";", "priv", ".", "fromIndex", "=", "priv", ".", "toIndex", ";", "priv", ".", "toIndex", "=", "toIndex", ";", "addMarkers", "(", "priv", ")", ";", "addTempClasses", "(", "priv", ")", ";", "priv", ".", "phaser", ".", "startTransition", "(", ")", ";", "emitEvent", "(", "priv", ",", "slidechange", "(", "priv", ".", "fromIndex", ",", "priv", ".", "toIndex", ")", ")", ";", "}" ]
Moves slider slide of given index. @param {Number} index index of the slide that slider will be moved to @precondition ${link Slider.prototype.start} was called on this slider @fqn Slider.prototype.moveTo
[ "Moves", "slider", "slide", "of", "given", "index", "." ]
2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4
https://github.com/mchalapuk/hyper-text-slider/blob/2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4/lib/core/slider.js#L210-L230
44,597
mchalapuk/hyper-text-slider
lib/core/slider.js
on
function on(priv, eventName, listener) { check(eventName, 'eventName').is.aString.and.oneOf(EVENT_NAMES)(); check(listener, 'listener').is.aFunction(); getListeners(priv, eventName).push(listener); }
javascript
function on(priv, eventName, listener) { check(eventName, 'eventName').is.aString.and.oneOf(EVENT_NAMES)(); check(listener, 'listener').is.aFunction(); getListeners(priv, eventName).push(listener); }
[ "function", "on", "(", "priv", ",", "eventName", ",", "listener", ")", "{", "check", "(", "eventName", ",", "'eventName'", ")", ".", "is", ".", "aString", ".", "and", ".", "oneOf", "(", "EVENT_NAMES", ")", "(", ")", ";", "check", "(", "listener", ",", "'listener'", ")", ".", "is", ".", "aFunction", "(", ")", ";", "getListeners", "(", "priv", ",", "eventName", ")", ".", "push", "(", "listener", ")", ";", "}" ]
Registers a listener on given eventName. @param {String} eventName name of event @param {Function} listener a function @postcondition given listener will be notified about current slide changes @fqn Slider.prototype.on
[ "Registers", "a", "listener", "on", "given", "eventName", "." ]
2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4
https://github.com/mchalapuk/hyper-text-slider/blob/2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4/lib/core/slider.js#L240-L245
44,598
mchalapuk/hyper-text-slider
lib/core/slider.js
removeListener
function removeListener(priv, eventName, listener) { check(eventName, 'eventName').is.aString.and.oneOf(EVENT_NAMES)(); var listeners = getListeners(priv, eventName); check(listener, 'listener').is.aFunction.and.is.oneOf(listeners, 'registered listeners')(); listeners.splice(listeners.indexOf(listener), 1); }
javascript
function removeListener(priv, eventName, listener) { check(eventName, 'eventName').is.aString.and.oneOf(EVENT_NAMES)(); var listeners = getListeners(priv, eventName); check(listener, 'listener').is.aFunction.and.is.oneOf(listeners, 'registered listeners')(); listeners.splice(listeners.indexOf(listener), 1); }
[ "function", "removeListener", "(", "priv", ",", "eventName", ",", "listener", ")", "{", "check", "(", "eventName", ",", "'eventName'", ")", ".", "is", ".", "aString", ".", "and", ".", "oneOf", "(", "EVENT_NAMES", ")", "(", ")", ";", "var", "listeners", "=", "getListeners", "(", "priv", ",", "eventName", ")", ";", "check", "(", "listener", ",", "'listener'", ")", ".", "is", ".", "aFunction", ".", "and", ".", "is", ".", "oneOf", "(", "listeners", ",", "'registered listeners'", ")", "(", ")", ";", "listeners", ".", "splice", "(", "listeners", ".", "indexOf", "(", "listener", ")", ",", "1", ")", ";", "}" ]
Unregisters a listener from given eventName. @param {String} eventName name of event @param {Function} listener a function @precondition given listener was previously passed to ${link Slider.prototype.on} @postcondition given listener will no longer be notified about current slide changes @fqn Slider.prototype.removeListener
[ "Unregisters", "a", "listener", "from", "given", "eventName", "." ]
2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4
https://github.com/mchalapuk/hyper-text-slider/blob/2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4/lib/core/slider.js#L256-L262
44,599
mchalapuk/hyper-text-slider
lib/core/slider.js
acceptSlide
function acceptSlide(priv, slideElement) { slideElement.classList.add(Flag.UPGRADED); insertSlide(priv, slideElement); priv.phaser.addPhaseTrigger(slideElement.querySelector('.'+ Layout.CONTENT)); if (priv.slides.length === 1) { priv.startCallback.call(null, priv.pub); // moving this to next tick is required in chromium for some reason window.setTimeout(moveToFirstSlide.bind(null, priv), 1); } }
javascript
function acceptSlide(priv, slideElement) { slideElement.classList.add(Flag.UPGRADED); insertSlide(priv, slideElement); priv.phaser.addPhaseTrigger(slideElement.querySelector('.'+ Layout.CONTENT)); if (priv.slides.length === 1) { priv.startCallback.call(null, priv.pub); // moving this to next tick is required in chromium for some reason window.setTimeout(moveToFirstSlide.bind(null, priv), 1); } }
[ "function", "acceptSlide", "(", "priv", ",", "slideElement", ")", "{", "slideElement", ".", "classList", ".", "add", "(", "Flag", ".", "UPGRADED", ")", ";", "insertSlide", "(", "priv", ",", "slideElement", ")", ";", "priv", ".", "phaser", ".", "addPhaseTrigger", "(", "slideElement", ".", "querySelector", "(", "'.'", "+", "Layout", ".", "CONTENT", ")", ")", ";", "if", "(", "priv", ".", "slides", ".", "length", "===", "1", ")", "{", "priv", ".", "startCallback", ".", "call", "(", "null", ",", "priv", ".", "pub", ")", ";", "// moving this to next tick is required in chromium for some reason", "window", ".", "setTimeout", "(", "moveToFirstSlide", ".", "bind", "(", "null", ",", "priv", ")", ",", "1", ")", ";", "}", "}" ]
private initialization functions
[ "private", "initialization", "functions" ]
2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4
https://github.com/mchalapuk/hyper-text-slider/blob/2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4/lib/core/slider.js#L268-L279