repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
partition
stringclasses
1 value
jstransformers/inputformat-to-jstransformer
build.js
finishedInstall
function finishedInstall(err) { if (err) { throw new Error(err) } const dictionary = {} for (const i in list) { if (list[i]) { const name = list[i] const transformer = require('jstransformer-' + name) // eslint-disable-line import/no-dynamic-require const formats = transformer.inputFormats || [name] for (const n in formats) { if (formats[n]) { const format = formats[n] // Ensure the input format exists in the dictionary. if (!dictionary[format]) { dictionary[format] = [] } // Add the package to the input format. dictionary[format].push('jstransformer-' + name) } } } } const sorted = sortJson(dictionary) fs.writeFileSync('dictionary.json', JSON.stringify(sorted, null, 2)) }
javascript
function finishedInstall(err) { if (err) { throw new Error(err) } const dictionary = {} for (const i in list) { if (list[i]) { const name = list[i] const transformer = require('jstransformer-' + name) // eslint-disable-line import/no-dynamic-require const formats = transformer.inputFormats || [name] for (const n in formats) { if (formats[n]) { const format = formats[n] // Ensure the input format exists in the dictionary. if (!dictionary[format]) { dictionary[format] = [] } // Add the package to the input format. dictionary[format].push('jstransformer-' + name) } } } } const sorted = sortJson(dictionary) fs.writeFileSync('dictionary.json', JSON.stringify(sorted, null, 2)) }
[ "function", "finishedInstall", "(", "err", ")", "{", "if", "(", "err", ")", "{", "throw", "new", "Error", "(", "err", ")", "}", "const", "dictionary", "=", "{", "}", "for", "(", "const", "i", "in", "list", ")", "{", "if", "(", "list", "[", "i", "]", ")", "{", "const", "name", "=", "list", "[", "i", "]", "const", "transformer", "=", "require", "(", "'jstransformer-'", "+", "name", ")", "const", "formats", "=", "transformer", ".", "inputFormats", "||", "[", "name", "]", "for", "(", "const", "n", "in", "formats", ")", "{", "if", "(", "formats", "[", "n", "]", ")", "{", "const", "format", "=", "formats", "[", "n", "]", "if", "(", "!", "dictionary", "[", "format", "]", ")", "{", "dictionary", "[", "format", "]", "=", "[", "]", "}", "dictionary", "[", "format", "]", ".", "push", "(", "'jstransformer-'", "+", "name", ")", "}", "}", "}", "}", "const", "sorted", "=", "sortJson", "(", "dictionary", ")", "fs", ".", "writeFileSync", "(", "'dictionary.json'", ",", "JSON", ".", "stringify", "(", "sorted", ",", "null", ",", "2", ")", ")", "}" ]
Write the dictionary.json based on the installed modules. @param {string} err The error that was reported.
[ "Write", "the", "dictionary", ".", "json", "based", "on", "the", "installed", "modules", "." ]
6e962561524f0bff7911d64f4be07dbc345800bf
https://github.com/jstransformers/inputformat-to-jstransformer/blob/6e962561524f0bff7911d64f4be07dbc345800bf/build.js#L34-L61
train
koa-modules/swig
index.js
setFilters
function setFilters(swig, filters) { for (var name in filters) { swig.setFilter(name, filters[name]); } }
javascript
function setFilters(swig, filters) { for (var name in filters) { swig.setFilter(name, filters[name]); } }
[ "function", "setFilters", "(", "swig", ",", "filters", ")", "{", "for", "(", "var", "name", "in", "filters", ")", "{", "swig", ".", "setFilter", "(", "name", ",", "filters", "[", "name", "]", ")", ";", "}", "}" ]
Add filters for Swig
[ "Add", "filters", "for", "Swig" ]
bcc02c5ef84210d8fc5fbc8ae809579fcecca4cb
https://github.com/koa-modules/swig/blob/bcc02c5ef84210d8fc5fbc8ae809579fcecca4cb/index.js#L146-L150
train
koa-modules/swig
index.js
setTags
function setTags(swig, tags) { var name, tag; for (name in tags) { tag = tags[name]; swig.setTag(name, tag.parse, tag.compile, tag.ends, tag.blockLevel); } }
javascript
function setTags(swig, tags) { var name, tag; for (name in tags) { tag = tags[name]; swig.setTag(name, tag.parse, tag.compile, tag.ends, tag.blockLevel); } }
[ "function", "setTags", "(", "swig", ",", "tags", ")", "{", "var", "name", ",", "tag", ";", "for", "(", "name", "in", "tags", ")", "{", "tag", "=", "tags", "[", "name", "]", ";", "swig", ".", "setTag", "(", "name", ",", "tag", ".", "parse", ",", "tag", ".", "compile", ",", "tag", ".", "ends", ",", "tag", ".", "blockLevel", ")", ";", "}", "}" ]
Add tags for Swig
[ "Add", "tags", "for", "Swig" ]
bcc02c5ef84210d8fc5fbc8ae809579fcecca4cb
https://github.com/koa-modules/swig/blob/bcc02c5ef84210d8fc5fbc8ae809579fcecca4cb/index.js#L156-L162
train
koa-modules/swig
index.js
setExtensions
function setExtensions(swig, extensions) { for (var name in extensions) { swig.setExtension(name, extensions[name]); } }
javascript
function setExtensions(swig, extensions) { for (var name in extensions) { swig.setExtension(name, extensions[name]); } }
[ "function", "setExtensions", "(", "swig", ",", "extensions", ")", "{", "for", "(", "var", "name", "in", "extensions", ")", "{", "swig", ".", "setExtension", "(", "name", ",", "extensions", "[", "name", "]", ")", ";", "}", "}" ]
Add extensions for Swig
[ "Add", "extensions", "for", "Swig" ]
bcc02c5ef84210d8fc5fbc8ae809579fcecca4cb
https://github.com/koa-modules/swig/blob/bcc02c5ef84210d8fc5fbc8ae809579fcecca4cb/index.js#L168-L174
train
stefanullinger/grunt-twig-render
Gruntfile.js
function (token, context, chain) { var // Parse the output without any filter unfiltered = Twig.parse.apply(this, [token.output, context]), // A regular expression to find closing and opening tags with spaces between them rBetweenTagSpaces = />\s+</g, // Replace all space between closing and opening html tags output = unfiltered.replace(rBetweenTagSpaces,'><').trim(); return { chain: chain, output: output }; }
javascript
function (token, context, chain) { var // Parse the output without any filter unfiltered = Twig.parse.apply(this, [token.output, context]), // A regular expression to find closing and opening tags with spaces between them rBetweenTagSpaces = />\s+</g, // Replace all space between closing and opening html tags output = unfiltered.replace(rBetweenTagSpaces,'><').trim(); return { chain: chain, output: output }; }
[ "function", "(", "token", ",", "context", ",", "chain", ")", "{", "var", "unfiltered", "=", "Twig", ".", "parse", ".", "apply", "(", "this", ",", "[", "token", ".", "output", ",", "context", "]", ")", ",", "rBetweenTagSpaces", "=", "/", ">\\s+<", "/", "g", ",", "output", "=", "unfiltered", ".", "replace", "(", "rBetweenTagSpaces", ",", "'><'", ")", ".", "trim", "(", ")", ";", "return", "{", "chain", ":", "chain", ",", "output", ":", "output", "}", ";", "}" ]
Parse the html and return it without any spaces between tags
[ "Parse", "the", "html", "and", "return", "it", "without", "any", "spaces", "between", "tags" ]
407c1f68026a27801af5445d8c254eb23967094f
https://github.com/stefanullinger/grunt-twig-render/blob/407c1f68026a27801af5445d8c254eb23967094f/Gruntfile.js#L231-L242
train
dannygarcia/grunt-jekyll
tasks/jekyll.js
configContext
function configContext (next) { if (options.raw) { // Tmp file is only available within the context of this function tmp.file({ prefix: '_config.', postfix: '.yml' }, function (err, path, fd) { rawConfigFile = path; if (err) { grunt.fail.warn(err); } // Write raw to file fs.writeSync(fd, new Buffer(options.raw), 0, options.raw.length); next(); }); } else { next(); } }
javascript
function configContext (next) { if (options.raw) { // Tmp file is only available within the context of this function tmp.file({ prefix: '_config.', postfix: '.yml' }, function (err, path, fd) { rawConfigFile = path; if (err) { grunt.fail.warn(err); } // Write raw to file fs.writeSync(fd, new Buffer(options.raw), 0, options.raw.length); next(); }); } else { next(); } }
[ "function", "configContext", "(", "next", ")", "{", "if", "(", "options", ".", "raw", ")", "{", "tmp", ".", "file", "(", "{", "prefix", ":", "'_config.'", ",", "postfix", ":", "'.yml'", "}", ",", "function", "(", "err", ",", "path", ",", "fd", ")", "{", "rawConfigFile", "=", "path", ";", "if", "(", "err", ")", "{", "grunt", ".", "fail", ".", "warn", "(", "err", ")", ";", "}", "fs", ".", "writeSync", "(", "fd", ",", "new", "Buffer", "(", "options", ".", "raw", ")", ",", "0", ",", "options", ".", "raw", ".", "length", ")", ";", "next", "(", ")", ";", "}", ")", ";", "}", "else", "{", "next", "(", ")", ";", "}", "}" ]
Create temporary config file if needed
[ "Create", "temporary", "config", "file", "if", "needed" ]
24009febfb119fc4468710bab462f64f388b030a
https://github.com/dannygarcia/grunt-jekyll/blob/24009febfb119fc4468710bab462f64f388b030a/tasks/jekyll.js#L73-L92
train
filamentgroup/grunticon-lib
static/grunticon.embed.js
function(stylesheet, refresh){ if( icons && !refresh ){ return icons; } icons = {}; // get grunticon stylesheet by its href var svgss, rules, cssText, iconClass, iconSVGEncoded, iconSVGRaw; svgss = stylesheet.sheet; if( !svgss ){ return icons; } rules = svgss.cssRules ? svgss.cssRules : svgss.rules; for( var i = 0; i < rules.length; i++ ){ cssText = rules[ i ].cssText; iconClass = selectorPlaceholder + rules[ i ].selectorText; iconSVGEncoded = cssText.split( ");" )[ 0 ].match( /US\-ASCII\,([^"']+)/ ); if( iconSVGEncoded && iconSVGEncoded[ 1 ] ){ iconSVGRaw = decodeURIComponent( iconSVGEncoded[ 1 ] ); icons[ iconClass ] = iconSVGRaw; } } return icons; }
javascript
function(stylesheet, refresh){ if( icons && !refresh ){ return icons; } icons = {}; // get grunticon stylesheet by its href var svgss, rules, cssText, iconClass, iconSVGEncoded, iconSVGRaw; svgss = stylesheet.sheet; if( !svgss ){ return icons; } rules = svgss.cssRules ? svgss.cssRules : svgss.rules; for( var i = 0; i < rules.length; i++ ){ cssText = rules[ i ].cssText; iconClass = selectorPlaceholder + rules[ i ].selectorText; iconSVGEncoded = cssText.split( ");" )[ 0 ].match( /US\-ASCII\,([^"']+)/ ); if( iconSVGEncoded && iconSVGEncoded[ 1 ] ){ iconSVGRaw = decodeURIComponent( iconSVGEncoded[ 1 ] ); icons[ iconClass ] = iconSVGRaw; } } return icons; }
[ "function", "(", "stylesheet", ",", "refresh", ")", "{", "if", "(", "icons", "&&", "!", "refresh", ")", "{", "return", "icons", ";", "}", "icons", "=", "{", "}", ";", "var", "svgss", ",", "rules", ",", "cssText", ",", "iconClass", ",", "iconSVGEncoded", ",", "iconSVGRaw", ";", "svgss", "=", "stylesheet", ".", "sheet", ";", "if", "(", "!", "svgss", ")", "{", "return", "icons", ";", "}", "rules", "=", "svgss", ".", "cssRules", "?", "svgss", ".", "cssRules", ":", "svgss", ".", "rules", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "rules", ".", "length", ";", "i", "++", ")", "{", "cssText", "=", "rules", "[", "i", "]", ".", "cssText", ";", "iconClass", "=", "selectorPlaceholder", "+", "rules", "[", "i", "]", ".", "selectorText", ";", "iconSVGEncoded", "=", "cssText", ".", "split", "(", "\");\"", ")", "[", "0", "]", ".", "match", "(", "/", "US\\-ASCII\\,([^\"']+)", "/", ")", ";", "if", "(", "iconSVGEncoded", "&&", "iconSVGEncoded", "[", "1", "]", ")", "{", "iconSVGRaw", "=", "decodeURIComponent", "(", "iconSVGEncoded", "[", "1", "]", ")", ";", "icons", "[", "iconClass", "]", "=", "iconSVGRaw", ";", "}", "}", "return", "icons", ";", "}" ]
this function can rip the svg markup from the css so we can embed it anywhere
[ "this", "function", "can", "rip", "the", "svg", "markup", "from", "the", "css", "so", "we", "can", "embed", "it", "anywhere" ]
2b7ecfe54a19a8d2429996cb456c7dd4ce04d71f
https://github.com/filamentgroup/grunticon-lib/blob/2b7ecfe54a19a8d2429996cb456c7dd4ce04d71f/static/grunticon.embed.js#L31-L59
train
tunnckoCoreLabs/get-installed-path
src/index.js
getInstalledPathSync
function getInstalledPathSync (name, opts) { if (!isValidString(name)) { throw new TypeError('get-installed-path: expect `name` to be string') } const filePaths = defaults(name, opts) const firstPath = filePaths[0] const modulePath = filePaths.find((filePath) => { let stat = null try { stat = fs.statSync(filePath) } catch (e) { return false } if (stat.isDirectory()) { return true } const msg = `Possibly "${name}" is not a directory: ${filePath}` throw new Error('get-installed-path: some error occured! ' + msg) }) if (!modulePath) { const label = 'get-installed-path:' const msg = `${label} module not found "${name}" in path ${firstPath}` throw new Error(msg) } return modulePath }
javascript
function getInstalledPathSync (name, opts) { if (!isValidString(name)) { throw new TypeError('get-installed-path: expect `name` to be string') } const filePaths = defaults(name, opts) const firstPath = filePaths[0] const modulePath = filePaths.find((filePath) => { let stat = null try { stat = fs.statSync(filePath) } catch (e) { return false } if (stat.isDirectory()) { return true } const msg = `Possibly "${name}" is not a directory: ${filePath}` throw new Error('get-installed-path: some error occured! ' + msg) }) if (!modulePath) { const label = 'get-installed-path:' const msg = `${label} module not found "${name}" in path ${firstPath}` throw new Error(msg) } return modulePath }
[ "function", "getInstalledPathSync", "(", "name", ",", "opts", ")", "{", "if", "(", "!", "isValidString", "(", "name", ")", ")", "{", "throw", "new", "TypeError", "(", "'get-installed-path: expect `name` to be string'", ")", "}", "const", "filePaths", "=", "defaults", "(", "name", ",", "opts", ")", "const", "firstPath", "=", "filePaths", "[", "0", "]", "const", "modulePath", "=", "filePaths", ".", "find", "(", "(", "filePath", ")", "=>", "{", "let", "stat", "=", "null", "try", "{", "stat", "=", "fs", ".", "statSync", "(", "filePath", ")", "}", "catch", "(", "e", ")", "{", "return", "false", "}", "if", "(", "stat", ".", "isDirectory", "(", ")", ")", "{", "return", "true", "}", "const", "msg", "=", "`", "${", "name", "}", "${", "filePath", "}", "`", "throw", "new", "Error", "(", "'get-installed-path: some error occured! '", "+", "msg", ")", "}", ")", "if", "(", "!", "modulePath", ")", "{", "const", "label", "=", "'get-installed-path:'", "const", "msg", "=", "`", "${", "label", "}", "${", "name", "}", "${", "firstPath", "}", "`", "throw", "new", "Error", "(", "msg", ")", "}", "return", "modulePath", "}" ]
> Get installed path of a `name` package synchronous. Returns `boolean` when `paths` option is used and filepath is directory, otherwise returns a full filepath OR throws error. @example const { getInstalledPathSync } = require('get-installed-path') const npmPath = getInstalledPathSync('npm') console.log(npmPath) // => '/home/charlike/.nvm/path/to/lib/node_modules/npm' const gmPath = getInstalledPathSync('global-modules', { local: true }) console.log(gmPath) // => '~/code/get-installed-path/node_modules/global-modules' @param {string} name package name @param {Object} opts pass `opts.local` to check locally @return {string} The full filepath or throw `TypeError` if `name` not a string or is empty string @name getInstalledPathSync @public
[ ">", "Get", "installed", "path", "of", "a", "name", "package", "synchronous", ".", "Returns", "boolean", "when", "paths", "option", "is", "used", "and", "filepath", "is", "directory", "otherwise", "returns", "a", "full", "filepath", "OR", "throws", "error", "." ]
e71687df4e972ee98bc8d1d4fe3d13e5f3a750f9
https://github.com/tunnckoCoreLabs/get-installed-path/blob/e71687df4e972ee98bc8d1d4fe3d13e5f3a750f9/src/index.js#L123-L154
train
bpmn-io/drag-tabs
index.js
DragTabs
function DragTabs($el, options) { // we are an event emitter assign(this, createEmitter()); this.options = options || {}; this.$el = $el; this._moveTab = bind(this._moveTab, this); this._onDragstart = bind(this._onDragstart, this); this._onDragend = bind(this._onDragend, this); this._onDrop = bind(this._onDrop, this); this._init(); this.update(); }
javascript
function DragTabs($el, options) { // we are an event emitter assign(this, createEmitter()); this.options = options || {}; this.$el = $el; this._moveTab = bind(this._moveTab, this); this._onDragstart = bind(this._onDragstart, this); this._onDragend = bind(this._onDragend, this); this._onDrop = bind(this._onDrop, this); this._init(); this.update(); }
[ "function", "DragTabs", "(", "$el", ",", "options", ")", "{", "assign", "(", "this", ",", "createEmitter", "(", ")", ")", ";", "this", ".", "options", "=", "options", "||", "{", "}", ";", "this", ".", "$el", "=", "$el", ";", "this", ".", "_moveTab", "=", "bind", "(", "this", ".", "_moveTab", ",", "this", ")", ";", "this", ".", "_onDragstart", "=", "bind", "(", "this", ".", "_onDragstart", ",", "this", ")", ";", "this", ".", "_onDragend", "=", "bind", "(", "this", ".", "_onDragend", ",", "this", ")", ";", "this", ".", "_onDrop", "=", "bind", "(", "this", ".", "_onDrop", ",", "this", ")", ";", "this", ".", "_init", "(", ")", ";", "this", ".", "update", "(", ")", ";", "}" ]
This component provides the infrastructure needed to move tabs around by dragging. It's not this component's responsibility to the actual moving of the tab, but exposing an event based interface that communicates when and where the tab dragging should happen. It makes sure all the tabs inside the intended container are draggable, ignoring the ones that are declared as so. The component is an event emitter and it emits the following events: - 'drag' is fired everytime there is a new position - 'end' is always fired at the end of the drag - 'cancel' is only fired when the dragging is canceled The three events are emitted with the following context: ```js var context = { dragTab: {HTMLElement}, newIndex: {Number} }; ``` @example: (1) provide a tabs-container: var $el = ( <div> <ul class="my-tabs-container"> <li class="my-tab"></li> <li class="my-tab"></li> <li class="my-tab ignore-me"></li> </ul> </div> ); (2) initialize dragTabs: var dragger = dragTabs(tabBarNode, { selectors: { tabsContainer: '.my-tabs-container', tab: '.my-tab', ignore: '.ignore-me' } }); (3) listen to the drag event: dragger.on('drag', function(context) { var dragTab = context.dragTab, newIndex = context.newIndex; // tab dragging logic }); (4) update the dragger if tabs change and or the tab container resizes: dragger.update(); @param {DOMElement} el @param {Object} options @param {Object} options.selectors @param {String} options.selectors.tabsContainer the container all tabs are contained in @param {String} options.selectors.tab a single tab inside the tab container @param {String} options.selectors.ignore tabs that should be ignored during scroll left/right @param {String} [options.showPreview=true] whether to show or hide the drag preview
[ "This", "component", "provides", "the", "infrastructure", "needed", "to", "move", "tabs", "around", "by", "dragging", "." ]
ce9299b969c0d2ed1eaa38195bb002a12a12873a
https://github.com/bpmn-io/drag-tabs/blob/ce9299b969c0d2ed1eaa38195bb002a12a12873a/index.js#L93-L109
train
nodemailer/nodemailer-smtp-pool
lib/smtp-pool.js
SMTPPool
function SMTPPool(options) { EventEmitter.call(this); options = options || {}; if (typeof options === 'string') { options = { url: options }; } var urlData; var service = options.service; if (typeof options.getSocket === 'function') { this.getSocket = options.getSocket; } if (options.url) { urlData = shared.parseConnectionUrl(options.url); service = service || urlData.service; } this.options = assign( false, // create new object options, // regular options urlData, // url options service && wellknown(service) // wellknown options ); this.options.maxConnections = this.options.maxConnections || 5; this.options.maxMessages = this.options.maxMessages || 100; this.logger = this.options.logger = shared.getLogger(this.options); // temporary object var connection = new SMTPConnection(this.options); this.name = 'SMTP (pool)'; this.version = packageData.version + '[client:' + connection.version + ']'; this._rateLimit = { counter: 0, timeout: null, waiting: [], checkpoint: false }; this._closed = false; this._queue = []; this._connections = []; this._connectionCounter = 0; this.idling = true; setImmediate(function () { if (this.idling) { this.emit('idle'); } }.bind(this)); }
javascript
function SMTPPool(options) { EventEmitter.call(this); options = options || {}; if (typeof options === 'string') { options = { url: options }; } var urlData; var service = options.service; if (typeof options.getSocket === 'function') { this.getSocket = options.getSocket; } if (options.url) { urlData = shared.parseConnectionUrl(options.url); service = service || urlData.service; } this.options = assign( false, // create new object options, // regular options urlData, // url options service && wellknown(service) // wellknown options ); this.options.maxConnections = this.options.maxConnections || 5; this.options.maxMessages = this.options.maxMessages || 100; this.logger = this.options.logger = shared.getLogger(this.options); // temporary object var connection = new SMTPConnection(this.options); this.name = 'SMTP (pool)'; this.version = packageData.version + '[client:' + connection.version + ']'; this._rateLimit = { counter: 0, timeout: null, waiting: [], checkpoint: false }; this._closed = false; this._queue = []; this._connections = []; this._connectionCounter = 0; this.idling = true; setImmediate(function () { if (this.idling) { this.emit('idle'); } }.bind(this)); }
[ "function", "SMTPPool", "(", "options", ")", "{", "EventEmitter", ".", "call", "(", "this", ")", ";", "options", "=", "options", "||", "{", "}", ";", "if", "(", "typeof", "options", "===", "'string'", ")", "{", "options", "=", "{", "url", ":", "options", "}", ";", "}", "var", "urlData", ";", "var", "service", "=", "options", ".", "service", ";", "if", "(", "typeof", "options", ".", "getSocket", "===", "'function'", ")", "{", "this", ".", "getSocket", "=", "options", ".", "getSocket", ";", "}", "if", "(", "options", ".", "url", ")", "{", "urlData", "=", "shared", ".", "parseConnectionUrl", "(", "options", ".", "url", ")", ";", "service", "=", "service", "||", "urlData", ".", "service", ";", "}", "this", ".", "options", "=", "assign", "(", "false", ",", "options", ",", "urlData", ",", "service", "&&", "wellknown", "(", "service", ")", ")", ";", "this", ".", "options", ".", "maxConnections", "=", "this", ".", "options", ".", "maxConnections", "||", "5", ";", "this", ".", "options", ".", "maxMessages", "=", "this", ".", "options", ".", "maxMessages", "||", "100", ";", "this", ".", "logger", "=", "this", ".", "options", ".", "logger", "=", "shared", ".", "getLogger", "(", "this", ".", "options", ")", ";", "var", "connection", "=", "new", "SMTPConnection", "(", "this", ".", "options", ")", ";", "this", ".", "name", "=", "'SMTP (pool)'", ";", "this", ".", "version", "=", "packageData", ".", "version", "+", "'[client:'", "+", "connection", ".", "version", "+", "']'", ";", "this", ".", "_rateLimit", "=", "{", "counter", ":", "0", ",", "timeout", ":", "null", ",", "waiting", ":", "[", "]", ",", "checkpoint", ":", "false", "}", ";", "this", ".", "_closed", "=", "false", ";", "this", ".", "_queue", "=", "[", "]", ";", "this", ".", "_connections", "=", "[", "]", ";", "this", ".", "_connectionCounter", "=", "0", ";", "this", ".", "idling", "=", "true", ";", "setImmediate", "(", "function", "(", ")", "{", "if", "(", "this", ".", "idling", ")", "{", "this", ".", "emit", "(", "'idle'", ")", ";", "}", "}", ".", "bind", "(", "this", ")", ")", ";", "}" ]
Creates a SMTP pool transport object for Nodemailer @constructor @param {Object} options SMTP Connection options
[ "Creates", "a", "SMTP", "pool", "transport", "object", "for", "Nodemailer" ]
db75ef6f16be7cfa05856fe0c66a9b459ec31556
https://github.com/nodemailer/nodemailer-smtp-pool/blob/db75ef6f16be7cfa05856fe0c66a9b459ec31556/lib/smtp-pool.js#L23-L81
train
nodemailer/nodemailer-smtp-pool
lib/pool-resource.js
PoolResource
function PoolResource(pool) { EventEmitter.call(this); this.pool = pool; this.options = pool.options; this.logger = this.options.logger; this._connection = false; this._connected = false; this.messages = 0; this.available = true; }
javascript
function PoolResource(pool) { EventEmitter.call(this); this.pool = pool; this.options = pool.options; this.logger = this.options.logger; this._connection = false; this._connected = false; this.messages = 0; this.available = true; }
[ "function", "PoolResource", "(", "pool", ")", "{", "EventEmitter", ".", "call", "(", "this", ")", ";", "this", ".", "pool", "=", "pool", ";", "this", ".", "options", "=", "pool", ".", "options", ";", "this", ".", "logger", "=", "this", ".", "options", ".", "logger", ";", "this", ".", "_connection", "=", "false", ";", "this", ".", "_connected", "=", "false", ";", "this", ".", "messages", "=", "0", ";", "this", ".", "available", "=", "true", ";", "}" ]
Creates an element for the pool @constructor @param {Object} options SMTPPool instance
[ "Creates", "an", "element", "for", "the", "pool" ]
db75ef6f16be7cfa05856fe0c66a9b459ec31556
https://github.com/nodemailer/nodemailer-smtp-pool/blob/db75ef6f16be7cfa05856fe0c66a9b459ec31556/lib/pool-resource.js#L16-L28
train
nolanlawson/chord-magic
src/reverseLookups.js
addReverseLookupsForExtendeds
function addReverseLookupsForExtendeds (reverseDict, dict) { Object.keys(dict).forEach(function (key) { let pair = dict[key] let quality = pair[0] let extendedsArr = pair[1] extendedsArr.forEach(function (element) { reverseDict[element] = { quality: quality, extended: key } }) }) }
javascript
function addReverseLookupsForExtendeds (reverseDict, dict) { Object.keys(dict).forEach(function (key) { let pair = dict[key] let quality = pair[0] let extendedsArr = pair[1] extendedsArr.forEach(function (element) { reverseDict[element] = { quality: quality, extended: key } }) }) }
[ "function", "addReverseLookupsForExtendeds", "(", "reverseDict", ",", "dict", ")", "{", "Object", ".", "keys", "(", "dict", ")", ".", "forEach", "(", "function", "(", "key", ")", "{", "let", "pair", "=", "dict", "[", "key", "]", "let", "quality", "=", "pair", "[", "0", "]", "let", "extendedsArr", "=", "pair", "[", "1", "]", "extendedsArr", ".", "forEach", "(", "function", "(", "element", ")", "{", "reverseDict", "[", "element", "]", "=", "{", "quality", ":", "quality", ",", "extended", ":", "key", "}", "}", ")", "}", ")", "}" ]
extendeds are a little different, because they contain both the quality and the extendeds
[ "extendeds", "are", "a", "little", "different", "because", "they", "contain", "both", "the", "quality", "and", "the", "extendeds" ]
822446a89737384421e2453c6e3602e8d434473b
https://github.com/nolanlawson/chord-magic/blob/822446a89737384421e2453c6e3602e8d434473b/src/reverseLookups.js#L43-L55
train
scijs/distance-transform
lib/pp.js
dist_p_sep
function dist_p_sep() { i = s[q] gi = array[ptr+i] gu = v var t = bisect(f, i, u+1, 0.25) return Math.floor(t) }
javascript
function dist_p_sep() { i = s[q] gi = array[ptr+i] gu = v var t = bisect(f, i, u+1, 0.25) return Math.floor(t) }
[ "function", "dist_p_sep", "(", ")", "{", "i", "=", "s", "[", "q", "]", "gi", "=", "array", "[", "ptr", "+", "i", "]", "gu", "=", "v", "var", "t", "=", "bisect", "(", "f", ",", "i", ",", "u", "+", "1", ",", "0.25", ")", "return", "Math", ".", "floor", "(", "t", ")", "}" ]
Not super efficient, but good enough for now
[ "Not", "super", "efficient", "but", "good", "enough", "for", "now" ]
10d2c34f4b7c9184ee9ce8d0309ce7fffacdc752
https://github.com/scijs/distance-transform/blob/10d2c34f4b7c9184ee9ce8d0309ce7fffacdc752/lib/pp.js#L20-L26
train
NaturalNode/apparatus
lib/apparatus/classifier/randomforest_classifier.js
predictOneDT
function predictOneDT(inst) { var n=0; for(var i=0;i<this.maxDepth;i++) { var dir= this.testFun(inst, this.models[n]); if(dir === 1) n= n*2+1; // descend left else n= n*2+2; // descend right } return (this.leafPositives[n] + 0.5) / (this.leafNegatives[n] + 1.0); // bayesian smoothing! }
javascript
function predictOneDT(inst) { var n=0; for(var i=0;i<this.maxDepth;i++) { var dir= this.testFun(inst, this.models[n]); if(dir === 1) n= n*2+1; // descend left else n= n*2+2; // descend right } return (this.leafPositives[n] + 0.5) / (this.leafNegatives[n] + 1.0); // bayesian smoothing! }
[ "function", "predictOneDT", "(", "inst", ")", "{", "var", "n", "=", "0", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "this", ".", "maxDepth", ";", "i", "++", ")", "{", "var", "dir", "=", "this", ".", "testFun", "(", "inst", ",", "this", ".", "models", "[", "n", "]", ")", ";", "if", "(", "dir", "===", "1", ")", "n", "=", "n", "*", "2", "+", "1", ";", "else", "n", "=", "n", "*", "2", "+", "2", ";", "}", "return", "(", "this", ".", "leafPositives", "[", "n", "]", "+", "0.5", ")", "/", "(", "this", ".", "leafNegatives", "[", "n", "]", "+", "1.0", ")", ";", "}" ]
returns probability that example inst is 1.
[ "returns", "probability", "that", "example", "inst", "is", "1", "." ]
861cf4cbb0775e2fd12ffaf30d01b7d8f9497e12
https://github.com/NaturalNode/apparatus/blob/861cf4cbb0775e2fd12ffaf30d01b7d8f9497e12/lib/apparatus/classifier/randomforest_classifier.js#L166-L176
train
NaturalNode/apparatus
lib/apparatus/classifier/randomforest_classifier.js
entropy
function entropy(labels, ix) { var N= ix.length; var p=0.0; for(var i=0;i<N;i++) { if(labels[ix[i]]==1) p+=1; } p=(1+p)/(N+2); // let's be bayesian about this q=(1+N-p)/(N+2); return (-p*Math.log(p) -q*Math.log(q)); }
javascript
function entropy(labels, ix) { var N= ix.length; var p=0.0; for(var i=0;i<N;i++) { if(labels[ix[i]]==1) p+=1; } p=(1+p)/(N+2); // let's be bayesian about this q=(1+N-p)/(N+2); return (-p*Math.log(p) -q*Math.log(q)); }
[ "function", "entropy", "(", "labels", ",", "ix", ")", "{", "var", "N", "=", "ix", ".", "length", ";", "var", "p", "=", "0.0", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "N", ";", "i", "++", ")", "{", "if", "(", "labels", "[", "ix", "[", "i", "]", "]", "==", "1", ")", "p", "+=", "1", ";", "}", "p", "=", "(", "1", "+", "p", ")", "/", "(", "N", "+", "2", ")", ";", "q", "=", "(", "1", "+", "N", "-", "p", ")", "/", "(", "N", "+", "2", ")", ";", "return", "(", "-", "p", "*", "Math", ".", "log", "(", "p", ")", "-", "q", "*", "Math", ".", "log", "(", "q", ")", ")", ";", "}" ]
Misc utility functions
[ "Misc", "utility", "functions" ]
861cf4cbb0775e2fd12ffaf30d01b7d8f9497e12
https://github.com/NaturalNode/apparatus/blob/861cf4cbb0775e2fd12ffaf30d01b7d8f9497e12/lib/apparatus/classifier/randomforest_classifier.js#L341-L350
train
8lueberry/bracket-template
src/node/LayoutTemplate.js
initConfig
function initConfig(conf) { const result = Object.assign({}, conf); if (conf.filename) { result.filepath = path.dirname(conf.filename); } return result; }
javascript
function initConfig(conf) { const result = Object.assign({}, conf); if (conf.filename) { result.filepath = path.dirname(conf.filename); } return result; }
[ "function", "initConfig", "(", "conf", ")", "{", "const", "result", "=", "Object", ".", "assign", "(", "{", "}", ",", "conf", ")", ";", "if", "(", "conf", ".", "filename", ")", "{", "result", ".", "filepath", "=", "path", ".", "dirname", "(", "conf", ".", "filename", ")", ";", "}", "return", "result", ";", "}" ]
Initialize the config @param {object} conf - The configuration
[ "Initialize", "the", "config" ]
b06390cc37f89d356e3e0fc01de3f7d54e49f988
https://github.com/8lueberry/bracket-template/blob/b06390cc37f89d356e3e0fc01de3f7d54e49f988/src/node/LayoutTemplate.js#L84-L90
train
8lueberry/bracket-template
src/node/LayoutTemplate.js
lookupFile
function lookupFile(conf, fileRelative) { const relativeToFile = path.resolve(conf.filepath, fileRelative); if (layoutHelper.store.exist(relativeToFile)) { return relativeToFile; } if (conf.settings && conf.settings.views) { if (!Array.isArray(conf.settings.views)) { const fromView = path.resolve(conf.settings.views, fileRelative); if (layoutHelper.store.exist(fromView)) { return fromView; } } for (let i = 0; i < conf.settings.views.length; i += 1) { const fromView = path.resolve(conf.settings.views[i], fileRelative); if (layoutHelper.store.exist(fromView)) { return fromView; } } } return relativeToFile; }
javascript
function lookupFile(conf, fileRelative) { const relativeToFile = path.resolve(conf.filepath, fileRelative); if (layoutHelper.store.exist(relativeToFile)) { return relativeToFile; } if (conf.settings && conf.settings.views) { if (!Array.isArray(conf.settings.views)) { const fromView = path.resolve(conf.settings.views, fileRelative); if (layoutHelper.store.exist(fromView)) { return fromView; } } for (let i = 0; i < conf.settings.views.length; i += 1) { const fromView = path.resolve(conf.settings.views[i], fileRelative); if (layoutHelper.store.exist(fromView)) { return fromView; } } } return relativeToFile; }
[ "function", "lookupFile", "(", "conf", ",", "fileRelative", ")", "{", "const", "relativeToFile", "=", "path", ".", "resolve", "(", "conf", ".", "filepath", ",", "fileRelative", ")", ";", "if", "(", "layoutHelper", ".", "store", ".", "exist", "(", "relativeToFile", ")", ")", "{", "return", "relativeToFile", ";", "}", "if", "(", "conf", ".", "settings", "&&", "conf", ".", "settings", ".", "views", ")", "{", "if", "(", "!", "Array", ".", "isArray", "(", "conf", ".", "settings", ".", "views", ")", ")", "{", "const", "fromView", "=", "path", ".", "resolve", "(", "conf", ".", "settings", ".", "views", ",", "fileRelative", ")", ";", "if", "(", "layoutHelper", ".", "store", ".", "exist", "(", "fromView", ")", ")", "{", "return", "fromView", ";", "}", "}", "for", "(", "let", "i", "=", "0", ";", "i", "<", "conf", ".", "settings", ".", "views", ".", "length", ";", "i", "+=", "1", ")", "{", "const", "fromView", "=", "path", ".", "resolve", "(", "conf", ".", "settings", ".", "views", "[", "i", "]", ",", "fileRelative", ")", ";", "if", "(", "layoutHelper", ".", "store", ".", "exist", "(", "fromView", ")", ")", "{", "return", "fromView", ";", "}", "}", "}", "return", "relativeToFile", ";", "}" ]
Lookup files for express from - relative to current file - relative to views @param {object} conf - The configuration @param {string} fileRelative - The relative path of the file
[ "Lookup", "files", "for", "express", "from", "-", "relative", "to", "current", "file", "-", "relative", "to", "views" ]
b06390cc37f89d356e3e0fc01de3f7d54e49f988
https://github.com/8lueberry/bracket-template/blob/b06390cc37f89d356e3e0fc01de3f7d54e49f988/src/node/LayoutTemplate.js#L141-L164
train
robeio/robe-react-ui
tools/server/MultierImpl.js
function (req, file, cb) { const id = guid(); file.id = id; fs.writeFileSync(path.normalize(tempFolder + "/" + id + ".json"), JSON.stringify(file), "utf8"); cb(null, id); }
javascript
function (req, file, cb) { const id = guid(); file.id = id; fs.writeFileSync(path.normalize(tempFolder + "/" + id + ".json"), JSON.stringify(file), "utf8"); cb(null, id); }
[ "function", "(", "req", ",", "file", ",", "cb", ")", "{", "const", "id", "=", "guid", "(", ")", ";", "file", ".", "id", "=", "id", ";", "fs", ".", "writeFileSync", "(", "path", ".", "normalize", "(", "tempFolder", "+", "\"/\"", "+", "id", "+", "\".json\"", ")", ",", "JSON", ".", "stringify", "(", "file", ")", ",", "\"utf8\"", ")", ";", "cb", "(", "null", ",", "id", ")", ";", "}" ]
Specifies upload location...
[ "Specifies", "upload", "location", "..." ]
46c76e037cbe0b5a6068202c16d4fd1a07c05ade
https://github.com/robeio/robe-react-ui/blob/46c76e037cbe0b5a6068202c16d4fd1a07c05ade/tools/server/MultierImpl.js#L39-L44
train
NoamELB/shouldComponentUpdate-Children
index.es.js
isReactElement
function isReactElement(suspectedElement) { var isElem = false; if (React.isValidElement(suspectedElement)) { isElem = true; } else if (Array.isArray(suspectedElement)) { for (var i = 0, l = suspectedElement.length; i < l; i++) { if (React.isValidElement(suspectedElement[i])) { isElem = true; break; } } } return isElem; }
javascript
function isReactElement(suspectedElement) { var isElem = false; if (React.isValidElement(suspectedElement)) { isElem = true; } else if (Array.isArray(suspectedElement)) { for (var i = 0, l = suspectedElement.length; i < l; i++) { if (React.isValidElement(suspectedElement[i])) { isElem = true; break; } } } return isElem; }
[ "function", "isReactElement", "(", "suspectedElement", ")", "{", "var", "isElem", "=", "false", ";", "if", "(", "React", ".", "isValidElement", "(", "suspectedElement", ")", ")", "{", "isElem", "=", "true", ";", "}", "else", "if", "(", "Array", ".", "isArray", "(", "suspectedElement", ")", ")", "{", "for", "(", "var", "i", "=", "0", ",", "l", "=", "suspectedElement", ".", "length", ";", "i", "<", "l", ";", "i", "++", ")", "{", "if", "(", "React", ".", "isValidElement", "(", "suspectedElement", "[", "i", "]", ")", ")", "{", "isElem", "=", "true", ";", "break", ";", "}", "}", "}", "return", "isElem", ";", "}" ]
If the provided argument is a valid react element or an array that contains at least one valid react element in it @param {*} suspectedElement @returns {Boolean}
[ "If", "the", "provided", "argument", "is", "a", "valid", "react", "element", "or", "an", "array", "that", "contains", "at", "least", "one", "valid", "react", "element", "in", "it" ]
3eb89296d8df1dc72ce6d862736e1789c13d0ac0
https://github.com/NoamELB/shouldComponentUpdate-Children/blob/3eb89296d8df1dc72ce6d862736e1789c13d0ac0/index.es.js#L130-L143
train
unshiftio/requests
index.js
initialize
function initialize(url) { this.socket = Requests[Requests.method](this); // // Open the socket BEFORE adding any properties to the instance as this might // trigger a thrown `InvalidStateError: An attempt was made to use an object // that is not, or is no longer, usable` error in FireFox: // // @see https://bugzilla.mozilla.org/show_bug.cgi?id=707484 // this.socket.open(this.method.toUpperCase(), url, true); // // Register this as an active HTTP request. // Requests.active[this.id] = this; }
javascript
function initialize(url) { this.socket = Requests[Requests.method](this); // // Open the socket BEFORE adding any properties to the instance as this might // trigger a thrown `InvalidStateError: An attempt was made to use an object // that is not, or is no longer, usable` error in FireFox: // // @see https://bugzilla.mozilla.org/show_bug.cgi?id=707484 // this.socket.open(this.method.toUpperCase(), url, true); // // Register this as an active HTTP request. // Requests.active[this.id] = this; }
[ "function", "initialize", "(", "url", ")", "{", "this", ".", "socket", "=", "Requests", "[", "Requests", ".", "method", "]", "(", "this", ")", ";", "this", ".", "socket", ".", "open", "(", "this", ".", "method", ".", "toUpperCase", "(", ")", ",", "url", ",", "true", ")", ";", "Requests", ".", "active", "[", "this", ".", "id", "]", "=", "this", ";", "}" ]
The requests instance has been fully initialized. @param {String} url The URL we need to connect to. @api private
[ "The", "requests", "instance", "has", "been", "fully", "initialized", "." ]
9f8da43c67381a74b09118703e921302cd45628a
https://github.com/unshiftio/requests/blob/9f8da43c67381a74b09118703e921302cd45628a/index.js#L47-L63
train
unshiftio/requests
index.js
open
function open() { var what , slice = true , requests = this , socket = requests.socket; requests.on('stream', function stream(data) { if (!slice) { return requests.emit('data', data); } // // Please note that we need to use a method here that works on both string // as well as ArrayBuffer's as we have no certainty that we're receiving // text. // var chunk = data.slice(requests.offset); requests.offset = data.length; requests.emit('data', chunk); }); requests.on('end', function cleanup() { delete Requests.active[requests.id]; }); if (this.timeout) { socket.timeout = +this.timeout; } if ('cors' === this.mode.toLowerCase() && 'withCredentials' in socket) { socket.withCredentials = true; } // // ActiveXObject will throw an `Type Mismatch` exception when setting the to // an null-value and to be consistent with all XHR implementations we're going // to cast the value to a string. // // While we don't technically support the XDomainRequest of IE, we do want to // double check that the setRequestHeader is available before adding headers. // // Chrome has a bug where it will actually append values to the header instead // of overriding it. So if you do a double setRequestHeader(Content-Type) with // text/plain and with text/plain again, it will end up as `text/plain, // text/plain` as header value. This is why use a headers object as it // already eliminates duplicate headers. // for (what in this.headers) { if (this.headers[what] !== undefined && this.socket.setRequestHeader) { this.socket.setRequestHeader(what, this.headers[what] +''); } } // // Set the correct responseType method. // if (requests.streaming) { if (!this.body || 'string' === typeof this.body) { if ('multipart' in socket) { socket.multipart = true; slice = false; } else if (Requests.type.mozchunkedtext) { socket.responseType = 'moz-chunked-text'; slice = false; } } else { if (Requests.type.mozchunkedarraybuffer) { socket.responseType = 'moz-chunked-arraybuffer'; } else if (Requests.type.msstream) { socket.responseType = 'ms-stream'; } } } listeners(socket, requests, requests.streaming); requests.emit('before', socket); send(socket, this.body, hang(function send(err) { if (err) { requests.emit('error', err); requests.emit('end', err); } requests.emit('send'); })); }
javascript
function open() { var what , slice = true , requests = this , socket = requests.socket; requests.on('stream', function stream(data) { if (!slice) { return requests.emit('data', data); } // // Please note that we need to use a method here that works on both string // as well as ArrayBuffer's as we have no certainty that we're receiving // text. // var chunk = data.slice(requests.offset); requests.offset = data.length; requests.emit('data', chunk); }); requests.on('end', function cleanup() { delete Requests.active[requests.id]; }); if (this.timeout) { socket.timeout = +this.timeout; } if ('cors' === this.mode.toLowerCase() && 'withCredentials' in socket) { socket.withCredentials = true; } // // ActiveXObject will throw an `Type Mismatch` exception when setting the to // an null-value and to be consistent with all XHR implementations we're going // to cast the value to a string. // // While we don't technically support the XDomainRequest of IE, we do want to // double check that the setRequestHeader is available before adding headers. // // Chrome has a bug where it will actually append values to the header instead // of overriding it. So if you do a double setRequestHeader(Content-Type) with // text/plain and with text/plain again, it will end up as `text/plain, // text/plain` as header value. This is why use a headers object as it // already eliminates duplicate headers. // for (what in this.headers) { if (this.headers[what] !== undefined && this.socket.setRequestHeader) { this.socket.setRequestHeader(what, this.headers[what] +''); } } // // Set the correct responseType method. // if (requests.streaming) { if (!this.body || 'string' === typeof this.body) { if ('multipart' in socket) { socket.multipart = true; slice = false; } else if (Requests.type.mozchunkedtext) { socket.responseType = 'moz-chunked-text'; slice = false; } } else { if (Requests.type.mozchunkedarraybuffer) { socket.responseType = 'moz-chunked-arraybuffer'; } else if (Requests.type.msstream) { socket.responseType = 'ms-stream'; } } } listeners(socket, requests, requests.streaming); requests.emit('before', socket); send(socket, this.body, hang(function send(err) { if (err) { requests.emit('error', err); requests.emit('end', err); } requests.emit('send'); })); }
[ "function", "open", "(", ")", "{", "var", "what", ",", "slice", "=", "true", ",", "requests", "=", "this", ",", "socket", "=", "requests", ".", "socket", ";", "requests", ".", "on", "(", "'stream'", ",", "function", "stream", "(", "data", ")", "{", "if", "(", "!", "slice", ")", "{", "return", "requests", ".", "emit", "(", "'data'", ",", "data", ")", ";", "}", "var", "chunk", "=", "data", ".", "slice", "(", "requests", ".", "offset", ")", ";", "requests", ".", "offset", "=", "data", ".", "length", ";", "requests", ".", "emit", "(", "'data'", ",", "chunk", ")", ";", "}", ")", ";", "requests", ".", "on", "(", "'end'", ",", "function", "cleanup", "(", ")", "{", "delete", "Requests", ".", "active", "[", "requests", ".", "id", "]", ";", "}", ")", ";", "if", "(", "this", ".", "timeout", ")", "{", "socket", ".", "timeout", "=", "+", "this", ".", "timeout", ";", "}", "if", "(", "'cors'", "===", "this", ".", "mode", ".", "toLowerCase", "(", ")", "&&", "'withCredentials'", "in", "socket", ")", "{", "socket", ".", "withCredentials", "=", "true", ";", "}", "for", "(", "what", "in", "this", ".", "headers", ")", "{", "if", "(", "this", ".", "headers", "[", "what", "]", "!==", "undefined", "&&", "this", ".", "socket", ".", "setRequestHeader", ")", "{", "this", ".", "socket", ".", "setRequestHeader", "(", "what", ",", "this", ".", "headers", "[", "what", "]", "+", "''", ")", ";", "}", "}", "if", "(", "requests", ".", "streaming", ")", "{", "if", "(", "!", "this", ".", "body", "||", "'string'", "===", "typeof", "this", ".", "body", ")", "{", "if", "(", "'multipart'", "in", "socket", ")", "{", "socket", ".", "multipart", "=", "true", ";", "slice", "=", "false", ";", "}", "else", "if", "(", "Requests", ".", "type", ".", "mozchunkedtext", ")", "{", "socket", ".", "responseType", "=", "'moz-chunked-text'", ";", "slice", "=", "false", ";", "}", "}", "else", "{", "if", "(", "Requests", ".", "type", ".", "mozchunkedarraybuffer", ")", "{", "socket", ".", "responseType", "=", "'moz-chunked-arraybuffer'", ";", "}", "else", "if", "(", "Requests", ".", "type", ".", "msstream", ")", "{", "socket", ".", "responseType", "=", "'ms-stream'", ";", "}", "}", "}", "listeners", "(", "socket", ",", "requests", ",", "requests", ".", "streaming", ")", ";", "requests", ".", "emit", "(", "'before'", ",", "socket", ")", ";", "send", "(", "socket", ",", "this", ".", "body", ",", "hang", "(", "function", "send", "(", "err", ")", "{", "if", "(", "err", ")", "{", "requests", ".", "emit", "(", "'error'", ",", "err", ")", ";", "requests", ".", "emit", "(", "'end'", ",", "err", ")", ";", "}", "requests", ".", "emit", "(", "'send'", ")", ";", "}", ")", ")", ";", "}" ]
Initialize and start requesting the supplied resource. @param {Object} options Passed in defaults. @api private
[ "Initialize", "and", "start", "requesting", "the", "supplied", "resource", "." ]
9f8da43c67381a74b09118703e921302cd45628a
https://github.com/unshiftio/requests/blob/9f8da43c67381a74b09118703e921302cd45628a/index.js#L71-L157
train
unshiftio/requests
index.js
destroy
function destroy() { if (!this.socket) return false; this.emit('destroy'); this.socket.abort(); this.removeAllListeners(); this.headers = {}; this.socket = null; this.body = null; delete Requests.active[this.id]; return true; }
javascript
function destroy() { if (!this.socket) return false; this.emit('destroy'); this.socket.abort(); this.removeAllListeners(); this.headers = {}; this.socket = null; this.body = null; delete Requests.active[this.id]; return true; }
[ "function", "destroy", "(", ")", "{", "if", "(", "!", "this", ".", "socket", ")", "return", "false", ";", "this", ".", "emit", "(", "'destroy'", ")", ";", "this", ".", "socket", ".", "abort", "(", ")", ";", "this", ".", "removeAllListeners", "(", ")", ";", "this", ".", "headers", "=", "{", "}", ";", "this", ".", "socket", "=", "null", ";", "this", ".", "body", "=", "null", ";", "delete", "Requests", ".", "active", "[", "this", ".", "id", "]", ";", "return", "true", ";", "}" ]
Completely destroy the running XHR and release of the internal references. @returns {Boolean} Successful destruction @api public
[ "Completely", "destroy", "the", "running", "XHR", "and", "release", "of", "the", "internal", "references", "." ]
9f8da43c67381a74b09118703e921302cd45628a
https://github.com/unshiftio/requests/blob/9f8da43c67381a74b09118703e921302cd45628a/index.js#L165-L180
train
chenglou/node-huxley
source/record/processActions.js
trimActions
function trimActions(actions) { // TODO: maybe, instead of doing this, add a last screenshot here. It's // mostly due to mistakes var lastScreenshotIndex = _.findLastIndex(actions, function(a) { return a.action === consts.STEP_SCREENSHOT; }); return actions.slice(0, lastScreenshotIndex + 1); }
javascript
function trimActions(actions) { // TODO: maybe, instead of doing this, add a last screenshot here. It's // mostly due to mistakes var lastScreenshotIndex = _.findLastIndex(actions, function(a) { return a.action === consts.STEP_SCREENSHOT; }); return actions.slice(0, lastScreenshotIndex + 1); }
[ "function", "trimActions", "(", "actions", ")", "{", "var", "lastScreenshotIndex", "=", "_", ".", "findLastIndex", "(", "actions", ",", "function", "(", "a", ")", "{", "return", "a", ".", "action", "===", "consts", ".", "STEP_SCREENSHOT", ";", "}", ")", ";", "return", "actions", ".", "slice", "(", "0", ",", "lastScreenshotIndex", "+", "1", ")", ";", "}" ]
every browser event happening after the last screenshot event is useless. Trim them
[ "every", "browser", "event", "happening", "after", "the", "last", "screenshot", "event", "is", "useless", ".", "Trim", "them" ]
fdee34c01cf835fc9571c396497ce48e494de43c
https://github.com/chenglou/node-huxley/blob/fdee34c01cf835fc9571c396497ce48e494de43c/source/record/processActions.js#L9-L16
train
chenglou/node-huxley
source/browser/browser.js
getBrowserName
function getBrowserName(driver) { var prom = new Promise(function(resolve, reject) { driver .getCapabilities() .then(function(res) { // damn it selenium, where's the js api docs var browserName = res.caps_ ? res.caps_.browserName : res.get('browserName') resolve(browserName); }, reject); }); return prom; }
javascript
function getBrowserName(driver) { var prom = new Promise(function(resolve, reject) { driver .getCapabilities() .then(function(res) { // damn it selenium, where's the js api docs var browserName = res.caps_ ? res.caps_.browserName : res.get('browserName') resolve(browserName); }, reject); }); return prom; }
[ "function", "getBrowserName", "(", "driver", ")", "{", "var", "prom", "=", "new", "Promise", "(", "function", "(", "resolve", ",", "reject", ")", "{", "driver", ".", "getCapabilities", "(", ")", ".", "then", "(", "function", "(", "res", ")", "{", "var", "browserName", "=", "res", ".", "caps_", "?", "res", ".", "caps_", ".", "browserName", ":", "res", ".", "get", "(", "'browserName'", ")", "resolve", "(", "browserName", ")", ";", "}", ",", "reject", ")", ";", "}", ")", ";", "return", "prom", ";", "}" ]
useful for getting the browser name of the injected driver
[ "useful", "for", "getting", "the", "browser", "name", "of", "the", "injected", "driver" ]
fdee34c01cf835fc9571c396497ce48e494de43c
https://github.com/chenglou/node-huxley/blob/fdee34c01cf835fc9571c396497ce48e494de43c/source/browser/browser.js#L85-L96
train
chenglou/node-huxley
source/defaultWorkflow/defaultWorkflow.js
defaultWorkflow
function defaultWorkflow(opts) { var tasks; var paths; var runnableTasks; var runnablePaths; return execP('git status') .then(function() { return getUnchanged(opts.globs); }) .spread(function(a, b) { tasks = a; paths = b; console.log( 'Executing: ' + '`git stash && git add . && git stash`.\n'.italic ); return gitCmds.safeStashAll(); }) .then(function() { console.log( 'Repo reverted to clean state. Looking at previous screenshots...\n' ); console.log( 'If anything goes wrong'.bold + ', simply run ' + '`git stash pop && git reset HEAD . && git stash pop --index` '.italic + 'to restore your changes.' ); // TODO: not good enough. Warn earlier about no task. Before stash var res = filterRunnables(tasks, paths, opts.taskName); runnableTasks = res[0]; runnablePaths = res[1]; return runTasks(writeScreenshots, opts, runnableTasks, runnablePaths); }) .catch(function(e) { if (e.name === 'OperationalError' && e.message.indexOf('Not a git repository') > -1) { return Promise.reject(new Error(notGitMsg)); } return gitCmds .safeUnstashAll() .then(function() { return Promise.reject(e); }); }) .then(function() { console.log( 'Executing: ' + '`git stash pop && git reset HEAD . && git stash pop --index`.\n'.italic ); return gitCmds.safeUnstashAll(); }) .then(function() { console.log( 'Repo back to modified state. Getting new screenshots and comparing ' + 'them with previously recorded ones...\n' ); return runTasks(compareScreenshots, opts, runnableTasks, runnablePaths); }) .then(function() { return Promise.map(paths, function(dir, i) { return Promise.map(tasks[i], function(task) { var p = path.join( dir, consts.HUXLEY_FOLDER_NAME, task.name + consts.TASK_FOLDER_SUFFIX ); return removeDirIfOk(p); }); }); }); }
javascript
function defaultWorkflow(opts) { var tasks; var paths; var runnableTasks; var runnablePaths; return execP('git status') .then(function() { return getUnchanged(opts.globs); }) .spread(function(a, b) { tasks = a; paths = b; console.log( 'Executing: ' + '`git stash && git add . && git stash`.\n'.italic ); return gitCmds.safeStashAll(); }) .then(function() { console.log( 'Repo reverted to clean state. Looking at previous screenshots...\n' ); console.log( 'If anything goes wrong'.bold + ', simply run ' + '`git stash pop && git reset HEAD . && git stash pop --index` '.italic + 'to restore your changes.' ); // TODO: not good enough. Warn earlier about no task. Before stash var res = filterRunnables(tasks, paths, opts.taskName); runnableTasks = res[0]; runnablePaths = res[1]; return runTasks(writeScreenshots, opts, runnableTasks, runnablePaths); }) .catch(function(e) { if (e.name === 'OperationalError' && e.message.indexOf('Not a git repository') > -1) { return Promise.reject(new Error(notGitMsg)); } return gitCmds .safeUnstashAll() .then(function() { return Promise.reject(e); }); }) .then(function() { console.log( 'Executing: ' + '`git stash pop && git reset HEAD . && git stash pop --index`.\n'.italic ); return gitCmds.safeUnstashAll(); }) .then(function() { console.log( 'Repo back to modified state. Getting new screenshots and comparing ' + 'them with previously recorded ones...\n' ); return runTasks(compareScreenshots, opts, runnableTasks, runnablePaths); }) .then(function() { return Promise.map(paths, function(dir, i) { return Promise.map(tasks[i], function(task) { var p = path.join( dir, consts.HUXLEY_FOLDER_NAME, task.name + consts.TASK_FOLDER_SUFFIX ); return removeDirIfOk(p); }); }); }); }
[ "function", "defaultWorkflow", "(", "opts", ")", "{", "var", "tasks", ";", "var", "paths", ";", "var", "runnableTasks", ";", "var", "runnablePaths", ";", "return", "execP", "(", "'git status'", ")", ".", "then", "(", "function", "(", ")", "{", "return", "getUnchanged", "(", "opts", ".", "globs", ")", ";", "}", ")", ".", "spread", "(", "function", "(", "a", ",", "b", ")", "{", "tasks", "=", "a", ";", "paths", "=", "b", ";", "console", ".", "log", "(", "'Executing: '", "+", "'`git stash && git add . && git stash`.\\n'", ".", "\\n", ")", ";", "italic", "}", ")", ".", "return", "gitCmds", ".", "safeStashAll", "(", ")", ";", "then", ".", "(", "function", "(", ")", "{", "console", ".", "log", "(", "'Repo reverted to clean state. Looking at previous screenshots...\\n'", ")", ";", "\\n", "console", ".", "log", "(", "'If anything goes wrong'", ".", "bold", "+", "', simply run '", "+", "'`git stash pop && git reset HEAD . && git stash pop --index` '", ".", "italic", "+", "'to restore your changes.'", ")", ";", "var", "res", "=", "filterRunnables", "(", "tasks", ",", "paths", ",", "opts", ".", "taskName", ")", ";", "runnableTasks", "=", "res", "[", "0", "]", ";", "runnablePaths", "=", "res", "[", "1", "]", ";", "}", ")", "return", "runTasks", "(", "writeScreenshots", ",", "opts", ",", "runnableTasks", ",", "runnablePaths", ")", ";", ".", "catch", "(", "function", "(", "e", ")", "{", "if", "(", "e", ".", "name", "===", "'OperationalError'", "&&", "e", ".", "message", ".", "indexOf", "(", "'Not a git repository'", ")", ">", "-", "1", ")", "{", "return", "Promise", ".", "reject", "(", "new", "Error", "(", "notGitMsg", ")", ")", ";", "}", "return", "gitCmds", ".", "safeUnstashAll", "(", ")", ".", "then", "(", "function", "(", ")", "{", "return", "Promise", ".", "reject", "(", "e", ")", ";", "}", ")", ";", "}", ")", ".", "then", "(", "function", "(", ")", "{", "console", ".", "log", "(", "'Executing: '", "+", "'`git stash pop && git reset HEAD . && git stash pop --index`.\\n'", ".", "\\n", ")", ";", "italic", "}", ")", ".", "return", "gitCmds", ".", "safeUnstashAll", "(", ")", ";", "then", ";", "}" ]
will support hg in the future
[ "will", "support", "hg", "in", "the", "future" ]
fdee34c01cf835fc9571c396497ce48e494de43c
https://github.com/chenglou/node-huxley/blob/fdee34c01cf835fc9571c396497ce48e494de43c/source/defaultWorkflow/defaultWorkflow.js#L26-L98
train
chenglou/node-huxley
source/defaultWorkflow/filterFilesForUnchangedTasks.js
filterFilesForUnchangedTasks
function filterFilesForUnchangedTasks(before, after, paths) { var pathsRes = []; var tasksRes = []; for (var i = 0; i < before.length; i++) { var unchangedTasks = filterUnchangedTasks(before[i], after[i]); if (unchangedTasks.length > 0) { tasksRes.push(unchangedTasks); pathsRes.push(paths[i]); } } return [tasksRes, pathsRes]; }
javascript
function filterFilesForUnchangedTasks(before, after, paths) { var pathsRes = []; var tasksRes = []; for (var i = 0; i < before.length; i++) { var unchangedTasks = filterUnchangedTasks(before[i], after[i]); if (unchangedTasks.length > 0) { tasksRes.push(unchangedTasks); pathsRes.push(paths[i]); } } return [tasksRes, pathsRes]; }
[ "function", "filterFilesForUnchangedTasks", "(", "before", ",", "after", ",", "paths", ")", "{", "var", "pathsRes", "=", "[", "]", ";", "var", "tasksRes", "=", "[", "]", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "before", ".", "length", ";", "i", "++", ")", "{", "var", "unchangedTasks", "=", "filterUnchangedTasks", "(", "before", "[", "i", "]", ",", "after", "[", "i", "]", ")", ";", "if", "(", "unchangedTasks", ".", "length", ">", "0", ")", "{", "tasksRes", ".", "push", "(", "unchangedTasks", ")", ";", "pathsRes", ".", "push", "(", "paths", "[", "i", "]", ")", ";", "}", "}", "return", "[", "tasksRes", ",", "pathsRes", "]", ";", "}" ]
trim each of the Huxleyfile content down to only tasks that are identical from the before copy and the after copy. Filter away the empty Huxleyfiles afterward
[ "trim", "each", "of", "the", "Huxleyfile", "content", "down", "to", "only", "tasks", "that", "are", "identical", "from", "the", "before", "copy", "and", "the", "after", "copy", ".", "Filter", "away", "the", "empty", "Huxleyfiles", "afterward" ]
fdee34c01cf835fc9571c396497ce48e494de43c
https://github.com/chenglou/node-huxley/blob/fdee34c01cf835fc9571c396497ce48e494de43c/source/defaultWorkflow/filterFilesForUnchangedTasks.js#L6-L19
train
node-ffi-napi/ref-struct-di
lib/struct.js
Struct
function Struct () { debug('defining new struct "type"') /** * This is the "constructor" of the Struct type that gets returned. * * Invoke it with `new` to create a new Buffer instance backing the struct. * Pass it an existing Buffer instance to use that as the backing buffer. * Pass in an Object containing the struct fields to auto-populate the * struct with the data. */ function StructType (arg, data) { if (!(this instanceof StructType)) { return new StructType(arg, data) } debug('creating new struct instance') var store if (Buffer.isBuffer(arg)) { debug('using passed-in Buffer instance to back the struct', arg) assert(arg.length >= StructType.size, 'Buffer instance must be at least ' + StructType.size + ' bytes to back this struct type') store = arg arg = data } else { debug('creating new Buffer instance to back the struct (size: %d)', StructType.size) store = new Buffer(StructType.size) } // set the backing Buffer store store.type = StructType this['ref.buffer'] = store if (arg) { for (var key in arg) { // hopefully hit the struct setters this[key] = arg[key] } } StructType._instanceCreated = true } // make instances inherit from the `proto` StructType.prototype = Object.create(proto, { constructor: { value: StructType , enumerable: false , writable: true , configurable: true } }) StructType.defineProperty = defineProperty StructType.toString = toString StructType.fields = {} var opt = (arguments.length > 0 && arguments[1]) ? arguments[1] : {}; // Setup the ref "type" interface. The constructor doubles as the "type" object StructType.size = 0 StructType.alignment = 0 StructType.indirection = 1 StructType.isPacked = opt.packed ? Boolean(opt.packed) : false StructType.get = get StructType.set = set // Read the fields list and apply all the fields to the struct // TODO: Better arg handling... (maybe look at ES6 binary data API?) var arg = arguments[0] if (Array.isArray(arg)) { // legacy API arg.forEach(function (a) { var type = a[0] var name = a[1] StructType.defineProperty(name, type) }) } else if (typeof arg === 'object') { Object.keys(arg).forEach(function (name) { var type = arg[name] StructType.defineProperty(name, type) }) } return StructType }
javascript
function Struct () { debug('defining new struct "type"') /** * This is the "constructor" of the Struct type that gets returned. * * Invoke it with `new` to create a new Buffer instance backing the struct. * Pass it an existing Buffer instance to use that as the backing buffer. * Pass in an Object containing the struct fields to auto-populate the * struct with the data. */ function StructType (arg, data) { if (!(this instanceof StructType)) { return new StructType(arg, data) } debug('creating new struct instance') var store if (Buffer.isBuffer(arg)) { debug('using passed-in Buffer instance to back the struct', arg) assert(arg.length >= StructType.size, 'Buffer instance must be at least ' + StructType.size + ' bytes to back this struct type') store = arg arg = data } else { debug('creating new Buffer instance to back the struct (size: %d)', StructType.size) store = new Buffer(StructType.size) } // set the backing Buffer store store.type = StructType this['ref.buffer'] = store if (arg) { for (var key in arg) { // hopefully hit the struct setters this[key] = arg[key] } } StructType._instanceCreated = true } // make instances inherit from the `proto` StructType.prototype = Object.create(proto, { constructor: { value: StructType , enumerable: false , writable: true , configurable: true } }) StructType.defineProperty = defineProperty StructType.toString = toString StructType.fields = {} var opt = (arguments.length > 0 && arguments[1]) ? arguments[1] : {}; // Setup the ref "type" interface. The constructor doubles as the "type" object StructType.size = 0 StructType.alignment = 0 StructType.indirection = 1 StructType.isPacked = opt.packed ? Boolean(opt.packed) : false StructType.get = get StructType.set = set // Read the fields list and apply all the fields to the struct // TODO: Better arg handling... (maybe look at ES6 binary data API?) var arg = arguments[0] if (Array.isArray(arg)) { // legacy API arg.forEach(function (a) { var type = a[0] var name = a[1] StructType.defineProperty(name, type) }) } else if (typeof arg === 'object') { Object.keys(arg).forEach(function (name) { var type = arg[name] StructType.defineProperty(name, type) }) } return StructType }
[ "function", "Struct", "(", ")", "{", "debug", "(", "'defining new struct \"type\"'", ")", "function", "StructType", "(", "arg", ",", "data", ")", "{", "if", "(", "!", "(", "this", "instanceof", "StructType", ")", ")", "{", "return", "new", "StructType", "(", "arg", ",", "data", ")", "}", "debug", "(", "'creating new struct instance'", ")", "var", "store", "if", "(", "Buffer", ".", "isBuffer", "(", "arg", ")", ")", "{", "debug", "(", "'using passed-in Buffer instance to back the struct'", ",", "arg", ")", "assert", "(", "arg", ".", "length", ">=", "StructType", ".", "size", ",", "'Buffer instance must be at least '", "+", "StructType", ".", "size", "+", "' bytes to back this struct type'", ")", "store", "=", "arg", "arg", "=", "data", "}", "else", "{", "debug", "(", "'creating new Buffer instance to back the struct (size: %d)'", ",", "StructType", ".", "size", ")", "store", "=", "new", "Buffer", "(", "StructType", ".", "size", ")", "}", "store", ".", "type", "=", "StructType", "this", "[", "'ref.buffer'", "]", "=", "store", "if", "(", "arg", ")", "{", "for", "(", "var", "key", "in", "arg", ")", "{", "this", "[", "key", "]", "=", "arg", "[", "key", "]", "}", "}", "StructType", ".", "_instanceCreated", "=", "true", "}", "StructType", ".", "prototype", "=", "Object", ".", "create", "(", "proto", ",", "{", "constructor", ":", "{", "value", ":", "StructType", ",", "enumerable", ":", "false", ",", "writable", ":", "true", ",", "configurable", ":", "true", "}", "}", ")", "StructType", ".", "defineProperty", "=", "defineProperty", "StructType", ".", "toString", "=", "toString", "StructType", ".", "fields", "=", "{", "}", "var", "opt", "=", "(", "arguments", ".", "length", ">", "0", "&&", "arguments", "[", "1", "]", ")", "?", "arguments", "[", "1", "]", ":", "{", "}", ";", "StructType", ".", "size", "=", "0", "StructType", ".", "alignment", "=", "0", "StructType", ".", "indirection", "=", "1", "StructType", ".", "isPacked", "=", "opt", ".", "packed", "?", "Boolean", "(", "opt", ".", "packed", ")", ":", "false", "StructType", ".", "get", "=", "get", "StructType", ".", "set", "=", "set", "var", "arg", "=", "arguments", "[", "0", "]", "if", "(", "Array", ".", "isArray", "(", "arg", ")", ")", "{", "arg", ".", "forEach", "(", "function", "(", "a", ")", "{", "var", "type", "=", "a", "[", "0", "]", "var", "name", "=", "a", "[", "1", "]", "StructType", ".", "defineProperty", "(", "name", ",", "type", ")", "}", ")", "}", "else", "if", "(", "typeof", "arg", "===", "'object'", ")", "{", "Object", ".", "keys", "(", "arg", ")", ".", "forEach", "(", "function", "(", "name", ")", "{", "var", "type", "=", "arg", "[", "name", "]", "StructType", ".", "defineProperty", "(", "name", ",", "type", ")", "}", ")", "}", "return", "StructType", "}" ]
The Struct "type" meta-constructor.
[ "The", "Struct", "type", "meta", "-", "constructor", "." ]
84fbaa8cdefbe24be76e8f5c3cbf5ae306965cda
https://github.com/node-ffi-napi/ref-struct-di/blob/84fbaa8cdefbe24be76e8f5c3cbf5ae306965cda/lib/struct.js#L63-L146
train
node-ffi-napi/ref-struct-di
lib/struct.js
StructType
function StructType (arg, data) { if (!(this instanceof StructType)) { return new StructType(arg, data) } debug('creating new struct instance') var store if (Buffer.isBuffer(arg)) { debug('using passed-in Buffer instance to back the struct', arg) assert(arg.length >= StructType.size, 'Buffer instance must be at least ' + StructType.size + ' bytes to back this struct type') store = arg arg = data } else { debug('creating new Buffer instance to back the struct (size: %d)', StructType.size) store = new Buffer(StructType.size) } // set the backing Buffer store store.type = StructType this['ref.buffer'] = store if (arg) { for (var key in arg) { // hopefully hit the struct setters this[key] = arg[key] } } StructType._instanceCreated = true }
javascript
function StructType (arg, data) { if (!(this instanceof StructType)) { return new StructType(arg, data) } debug('creating new struct instance') var store if (Buffer.isBuffer(arg)) { debug('using passed-in Buffer instance to back the struct', arg) assert(arg.length >= StructType.size, 'Buffer instance must be at least ' + StructType.size + ' bytes to back this struct type') store = arg arg = data } else { debug('creating new Buffer instance to back the struct (size: %d)', StructType.size) store = new Buffer(StructType.size) } // set the backing Buffer store store.type = StructType this['ref.buffer'] = store if (arg) { for (var key in arg) { // hopefully hit the struct setters this[key] = arg[key] } } StructType._instanceCreated = true }
[ "function", "StructType", "(", "arg", ",", "data", ")", "{", "if", "(", "!", "(", "this", "instanceof", "StructType", ")", ")", "{", "return", "new", "StructType", "(", "arg", ",", "data", ")", "}", "debug", "(", "'creating new struct instance'", ")", "var", "store", "if", "(", "Buffer", ".", "isBuffer", "(", "arg", ")", ")", "{", "debug", "(", "'using passed-in Buffer instance to back the struct'", ",", "arg", ")", "assert", "(", "arg", ".", "length", ">=", "StructType", ".", "size", ",", "'Buffer instance must be at least '", "+", "StructType", ".", "size", "+", "' bytes to back this struct type'", ")", "store", "=", "arg", "arg", "=", "data", "}", "else", "{", "debug", "(", "'creating new Buffer instance to back the struct (size: %d)'", ",", "StructType", ".", "size", ")", "store", "=", "new", "Buffer", "(", "StructType", ".", "size", ")", "}", "store", ".", "type", "=", "StructType", "this", "[", "'ref.buffer'", "]", "=", "store", "if", "(", "arg", ")", "{", "for", "(", "var", "key", "in", "arg", ")", "{", "this", "[", "key", "]", "=", "arg", "[", "key", "]", "}", "}", "StructType", ".", "_instanceCreated", "=", "true", "}" ]
This is the "constructor" of the Struct type that gets returned. Invoke it with `new` to create a new Buffer instance backing the struct. Pass it an existing Buffer instance to use that as the backing buffer. Pass in an Object containing the struct fields to auto-populate the struct with the data.
[ "This", "is", "the", "constructor", "of", "the", "Struct", "type", "that", "gets", "returned", "." ]
84fbaa8cdefbe24be76e8f5c3cbf5ae306965cda
https://github.com/node-ffi-napi/ref-struct-di/blob/84fbaa8cdefbe24be76e8f5c3cbf5ae306965cda/lib/struct.js#L75-L103
train
node-ffi-napi/ref-struct-di
lib/struct.js
set
function set (buffer, offset, value) { debug('Struct "type" setter for buffer at offset', buffer, offset, value) var isStruct = value instanceof this if (isStruct) { // optimization: copy the buffer contents directly rather // than going through the ref-struct constructor value['ref.buffer'].copy(buffer, offset, 0, this.size) } else { if (offset > 0) { buffer = buffer.slice(offset) } new this(buffer, value) } }
javascript
function set (buffer, offset, value) { debug('Struct "type" setter for buffer at offset', buffer, offset, value) var isStruct = value instanceof this if (isStruct) { // optimization: copy the buffer contents directly rather // than going through the ref-struct constructor value['ref.buffer'].copy(buffer, offset, 0, this.size) } else { if (offset > 0) { buffer = buffer.slice(offset) } new this(buffer, value) } }
[ "function", "set", "(", "buffer", ",", "offset", ",", "value", ")", "{", "debug", "(", "'Struct \"type\" setter for buffer at offset'", ",", "buffer", ",", "offset", ",", "value", ")", "var", "isStruct", "=", "value", "instanceof", "this", "if", "(", "isStruct", ")", "{", "value", "[", "'ref.buffer'", "]", ".", "copy", "(", "buffer", ",", "offset", ",", "0", ",", "this", ".", "size", ")", "}", "else", "{", "if", "(", "offset", ">", "0", ")", "{", "buffer", "=", "buffer", ".", "slice", "(", "offset", ")", "}", "new", "this", "(", "buffer", ",", "value", ")", "}", "}" ]
The "set" function of the Struct "type" interface
[ "The", "set", "function", "of", "the", "Struct", "type", "interface" ]
84fbaa8cdefbe24be76e8f5c3cbf5ae306965cda
https://github.com/node-ffi-napi/ref-struct-di/blob/84fbaa8cdefbe24be76e8f5c3cbf5ae306965cda/lib/struct.js#L164-L177
train
ariatemplates/ariatemplates
src/aria/widgets/form/Gauge.js
function (out) { var skinObj = this._skinObj, cfg = this._cfg; out.write(['<div class="x', this._skinnableClass, '_', cfg.sclass, '" style="float:left;position:relative', skinObj.border ? ';border:' + skinObj.border : '', skinObj.borderPadding ? ';padding:' + skinObj.borderPadding + 'px' : '', ';height:', skinObj.sprHeight, 'px;width:', cfg.gaugeWidth, 'px;">'].join("")); }
javascript
function (out) { var skinObj = this._skinObj, cfg = this._cfg; out.write(['<div class="x', this._skinnableClass, '_', cfg.sclass, '" style="float:left;position:relative', skinObj.border ? ';border:' + skinObj.border : '', skinObj.borderPadding ? ';padding:' + skinObj.borderPadding + 'px' : '', ';height:', skinObj.sprHeight, 'px;width:', cfg.gaugeWidth, 'px;">'].join("")); }
[ "function", "(", "out", ")", "{", "var", "skinObj", "=", "this", ".", "_skinObj", ",", "cfg", "=", "this", ".", "_cfg", ";", "out", ".", "write", "(", "[", "'<div class=\"x'", ",", "this", ".", "_skinnableClass", ",", "'_'", ",", "cfg", ".", "sclass", ",", "'\" style=\"float:left;position:relative'", ",", "skinObj", ".", "border", "?", "';border:'", "+", "skinObj", ".", "border", ":", "''", ",", "skinObj", ".", "borderPadding", "?", "';padding:'", "+", "skinObj", ".", "borderPadding", "+", "'px'", ":", "''", ",", "';height:'", ",", "skinObj", ".", "sprHeight", ",", "'px;width:'", ",", "cfg", ".", "gaugeWidth", ",", "'px;\">'", "]", ".", "join", "(", "\"\"", ")", ")", ";", "}" ]
Internal function to generate the internal widget begin markup @param {aria.templates.MarkupWriter} out @protected
[ "Internal", "function", "to", "generate", "the", "internal", "widget", "begin", "markup" ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/Gauge.js#L87-L93
train
ariatemplates/ariatemplates
src/aria/widgets/form/Gauge.js
function (out) { var skinObj = this._skinObj, cfg = this._cfg; out.write(['<span style="float:left;text-align:', cfg.labelAlign, skinObj.labelMargins ? ';margin:' + skinObj.labelMargins : '', skinObj.labelFontSize ? ';font-size:' + skinObj.labelFontSize + 'px' : '', cfg.labelWidth > -1 ? ';width:' + cfg.labelWidth + 'px' : '', '">', ariaUtilsString.escapeHTML(cfg.label), '</span>'].join("")); }
javascript
function (out) { var skinObj = this._skinObj, cfg = this._cfg; out.write(['<span style="float:left;text-align:', cfg.labelAlign, skinObj.labelMargins ? ';margin:' + skinObj.labelMargins : '', skinObj.labelFontSize ? ';font-size:' + skinObj.labelFontSize + 'px' : '', cfg.labelWidth > -1 ? ';width:' + cfg.labelWidth + 'px' : '', '">', ariaUtilsString.escapeHTML(cfg.label), '</span>'].join("")); }
[ "function", "(", "out", ")", "{", "var", "skinObj", "=", "this", ".", "_skinObj", ",", "cfg", "=", "this", ".", "_cfg", ";", "out", ".", "write", "(", "[", "'<span style=\"float:left;text-align:'", ",", "cfg", ".", "labelAlign", ",", "skinObj", ".", "labelMargins", "?", "';margin:'", "+", "skinObj", ".", "labelMargins", ":", "''", ",", "skinObj", ".", "labelFontSize", "?", "';font-size:'", "+", "skinObj", ".", "labelFontSize", "+", "'px'", ":", "''", ",", "cfg", ".", "labelWidth", ">", "-", "1", "?", "';width:'", "+", "cfg", ".", "labelWidth", "+", "'px'", ":", "''", ",", "'\">'", ",", "ariaUtilsString", ".", "escapeHTML", "(", "cfg", ".", "label", ")", ",", "'</span>'", "]", ".", "join", "(", "\"\"", ")", ")", ";", "}" ]
Internal function to generate the laebl markup @param {aria.templates.MarkupWriter} out @protected
[ "Internal", "function", "to", "generate", "the", "laebl", "markup" ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/Gauge.js#L100-L107
train
ariatemplates/ariatemplates
src/aria/widgets/form/Gauge.js
function () { if (!this._cfgOk) { return; } var cfg = this._cfg; if (cfg !== null) { if (cfg.minValue >= cfg.maxValue) { this.$logError(this.WIDGET_GAUGE_CFG_MIN_EQUAL_GREATER_MAX, []); this._cfgOk = false; return; } } }
javascript
function () { if (!this._cfgOk) { return; } var cfg = this._cfg; if (cfg !== null) { if (cfg.minValue >= cfg.maxValue) { this.$logError(this.WIDGET_GAUGE_CFG_MIN_EQUAL_GREATER_MAX, []); this._cfgOk = false; return; } } }
[ "function", "(", ")", "{", "if", "(", "!", "this", ".", "_cfgOk", ")", "{", "return", ";", "}", "var", "cfg", "=", "this", ".", "_cfg", ";", "if", "(", "cfg", "!==", "null", ")", "{", "if", "(", "cfg", ".", "minValue", ">=", "cfg", ".", "maxValue", ")", "{", "this", ".", "$logError", "(", "this", ".", "WIDGET_GAUGE_CFG_MIN_EQUAL_GREATER_MAX", ",", "[", "]", ")", ";", "this", ".", "_cfgOk", "=", "false", ";", "return", ";", "}", "}", "}" ]
Internal function to verify consistency of cfg @protected
[ "Internal", "function", "to", "verify", "consistency", "of", "cfg" ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/Gauge.js#L121-L134
train
ariatemplates/ariatemplates
src/aria/widgets/form/Gauge.js
function (newValue) { var gaugeSpanIndex = this.showLabel ? 1 : 0; var barEl = this.getDom().childNodes[gaugeSpanIndex].firstChild; var calcValue = this.__calculateBarWidth(newValue); if (barEl !== null && calcValue !== null && calcValue != -1) { barEl.style.width = calcValue + "%"; } barEl = null; }
javascript
function (newValue) { var gaugeSpanIndex = this.showLabel ? 1 : 0; var barEl = this.getDom().childNodes[gaugeSpanIndex].firstChild; var calcValue = this.__calculateBarWidth(newValue); if (barEl !== null && calcValue !== null && calcValue != -1) { barEl.style.width = calcValue + "%"; } barEl = null; }
[ "function", "(", "newValue", ")", "{", "var", "gaugeSpanIndex", "=", "this", ".", "showLabel", "?", "1", ":", "0", ";", "var", "barEl", "=", "this", ".", "getDom", "(", ")", ".", "childNodes", "[", "gaugeSpanIndex", "]", ".", "firstChild", ";", "var", "calcValue", "=", "this", ".", "__calculateBarWidth", "(", "newValue", ")", ";", "if", "(", "barEl", "!==", "null", "&&", "calcValue", "!==", "null", "&&", "calcValue", "!=", "-", "1", ")", "{", "barEl", ".", "style", ".", "width", "=", "calcValue", "+", "\"%\"", ";", "}", "barEl", "=", "null", ";", "}" ]
A private method to set the current value of the gauge @param {Integer} newValue The new value of the gauge @private
[ "A", "private", "method", "to", "set", "the", "current", "value", "of", "the", "gauge" ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/Gauge.js#L170-L178
train
ariatemplates/ariatemplates
src/aria/widgets/form/Gauge.js
function (newValue) { var barEl = this.getDom().childNodes[0]; if (barEl !== null) { barEl.innerHTML = newValue; } barEl = null; }
javascript
function (newValue) { var barEl = this.getDom().childNodes[0]; if (barEl !== null) { barEl.innerHTML = newValue; } barEl = null; }
[ "function", "(", "newValue", ")", "{", "var", "barEl", "=", "this", ".", "getDom", "(", ")", ".", "childNodes", "[", "0", "]", ";", "if", "(", "barEl", "!==", "null", ")", "{", "barEl", ".", "innerHTML", "=", "newValue", ";", "}", "barEl", "=", "null", ";", "}" ]
A private method to set the label text @param {String} newValue Label text @private
[ "A", "private", "method", "to", "set", "the", "label", "text" ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/Gauge.js#L184-L190
train
ariatemplates/ariatemplates
src/aria/widgets/form/Gauge.js
function (newValue) { if (!this._cfgOk) { return -1; } var cfg = this._cfg; var res = null; if (cfg !== null) { if (newValue !== null && newValue !== "" && newValue >= cfg.minValue && newValue <= cfg.maxValue) { res = ((newValue - cfg.minValue) / Math.abs(this._cfg.maxValue - this._cfg.minValue)) * 100; } else { res = -1; } } cfg = null; return res; }
javascript
function (newValue) { if (!this._cfgOk) { return -1; } var cfg = this._cfg; var res = null; if (cfg !== null) { if (newValue !== null && newValue !== "" && newValue >= cfg.minValue && newValue <= cfg.maxValue) { res = ((newValue - cfg.minValue) / Math.abs(this._cfg.maxValue - this._cfg.minValue)) * 100; } else { res = -1; } } cfg = null; return res; }
[ "function", "(", "newValue", ")", "{", "if", "(", "!", "this", ".", "_cfgOk", ")", "{", "return", "-", "1", ";", "}", "var", "cfg", "=", "this", ".", "_cfg", ";", "var", "res", "=", "null", ";", "if", "(", "cfg", "!==", "null", ")", "{", "if", "(", "newValue", "!==", "null", "&&", "newValue", "!==", "\"\"", "&&", "newValue", ">=", "cfg", ".", "minValue", "&&", "newValue", "<=", "cfg", ".", "maxValue", ")", "{", "res", "=", "(", "(", "newValue", "-", "cfg", ".", "minValue", ")", "/", "Math", ".", "abs", "(", "this", ".", "_cfg", ".", "maxValue", "-", "this", ".", "_cfg", ".", "minValue", ")", ")", "*", "100", ";", "}", "else", "{", "res", "=", "-", "1", ";", "}", "}", "cfg", "=", "null", ";", "return", "res", ";", "}" ]
A private method to calculate the progress bar width @param {Integer} newValue The new value of the gauge @return {Integer} The new bar width in percentage. If -1 the new width could not be calculated @private
[ "A", "private", "method", "to", "calculate", "the", "progress", "bar", "width" ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/Gauge.js#L197-L213
train
ariatemplates/ariatemplates
src/aria/widgets/container/Tab.js
function (skipChangeState) { var state = "normal"; var cfg = this._cfg; if (cfg.disabled) { state = "disabled"; } else if (cfg.tabId === cfg.selectedTab) { state = "selected"; } else { if (this._mouseOver) { state = "msover"; } } if (this._hasFocus) { state += "Focused"; } this._state = state; if (!skipChangeState) { // force widget - DOM mapping this.getDom(); this._frame.changeState(this._state); } }
javascript
function (skipChangeState) { var state = "normal"; var cfg = this._cfg; if (cfg.disabled) { state = "disabled"; } else if (cfg.tabId === cfg.selectedTab) { state = "selected"; } else { if (this._mouseOver) { state = "msover"; } } if (this._hasFocus) { state += "Focused"; } this._state = state; if (!skipChangeState) { // force widget - DOM mapping this.getDom(); this._frame.changeState(this._state); } }
[ "function", "(", "skipChangeState", ")", "{", "var", "state", "=", "\"normal\"", ";", "var", "cfg", "=", "this", ".", "_cfg", ";", "if", "(", "cfg", ".", "disabled", ")", "{", "state", "=", "\"disabled\"", ";", "}", "else", "if", "(", "cfg", ".", "tabId", "===", "cfg", ".", "selectedTab", ")", "{", "state", "=", "\"selected\"", ";", "}", "else", "{", "if", "(", "this", ".", "_mouseOver", ")", "{", "state", "=", "\"msover\"", ";", "}", "}", "if", "(", "this", ".", "_hasFocus", ")", "{", "state", "+=", "\"Focused\"", ";", "}", "this", ".", "_state", "=", "state", ";", "if", "(", "!", "skipChangeState", ")", "{", "this", ".", "getDom", "(", ")", ";", "this", ".", "_frame", ".", "changeState", "(", "this", ".", "_state", ")", ";", "}", "}" ]
Internal method to update the state of the tab, from the config and the mouse over variable @param {Boolean} skipChangeState - If true we don't update the state in the frame as the frame may not be initialized @protected
[ "Internal", "method", "to", "update", "the", "state", "of", "the", "tab", "from", "the", "config", "and", "the", "mouse", "over", "variable" ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/container/Tab.js#L481-L505
train
ariatemplates/ariatemplates
src/aria/widgets/container/Tab.js
function () { this.changeProperty("selectedTab", this._cfg.tabId); if (this._cfg.waiAria) { // Focusing the Tab before focusing the TabPanel is not enough to make the screen reader read the tab's title first // A sufficient timeout would be necessary, but we can't program that way safely // this._focus(); var controlledTabPanelId = this._getControlledTabPanelId(); if (controlledTabPanelId != null) { var tabPanelElement = ariaUtilsDom.getElementById(controlledTabPanelId); ariaTemplatesNavigationManager.focusFirst(tabPanelElement); } } }
javascript
function () { this.changeProperty("selectedTab", this._cfg.tabId); if (this._cfg.waiAria) { // Focusing the Tab before focusing the TabPanel is not enough to make the screen reader read the tab's title first // A sufficient timeout would be necessary, but we can't program that way safely // this._focus(); var controlledTabPanelId = this._getControlledTabPanelId(); if (controlledTabPanelId != null) { var tabPanelElement = ariaUtilsDom.getElementById(controlledTabPanelId); ariaTemplatesNavigationManager.focusFirst(tabPanelElement); } } }
[ "function", "(", ")", "{", "this", ".", "changeProperty", "(", "\"selectedTab\"", ",", "this", ".", "_cfg", ".", "tabId", ")", ";", "if", "(", "this", ".", "_cfg", ".", "waiAria", ")", "{", "var", "controlledTabPanelId", "=", "this", ".", "_getControlledTabPanelId", "(", ")", ";", "if", "(", "controlledTabPanelId", "!=", "null", ")", "{", "var", "tabPanelElement", "=", "ariaUtilsDom", ".", "getElementById", "(", "controlledTabPanelId", ")", ";", "ariaTemplatesNavigationManager", ".", "focusFirst", "(", "tabPanelElement", ")", ";", "}", "}", "}" ]
Set the current tab as selected @protected
[ "Set", "the", "current", "tab", "as", "selected" ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/container/Tab.js#L511-L523
train
ariatemplates/ariatemplates
src/aria/html/controllers/Suggestions.js
PromisedHandler
function PromisedHandler () { this.getSuggestions = function (entry, callback) { this.pendingSuggestion = { entry : entry, callback : callback }; }; this.getAllSuggestions = function (callback) { this.pendingSuggestion = { // there's no entry, in case you didn't notice callback : callback }; }; this.$dispose = Aria.empty; }
javascript
function PromisedHandler () { this.getSuggestions = function (entry, callback) { this.pendingSuggestion = { entry : entry, callback : callback }; }; this.getAllSuggestions = function (callback) { this.pendingSuggestion = { // there's no entry, in case you didn't notice callback : callback }; }; this.$dispose = Aria.empty; }
[ "function", "PromisedHandler", "(", ")", "{", "this", ".", "getSuggestions", "=", "function", "(", "entry", ",", "callback", ")", "{", "this", ".", "pendingSuggestion", "=", "{", "entry", ":", "entry", ",", "callback", ":", "callback", "}", ";", "}", ";", "this", ".", "getAllSuggestions", "=", "function", "(", "callback", ")", "{", "this", ".", "pendingSuggestion", "=", "{", "callback", ":", "callback", "}", ";", "}", ";", "this", ".", "$dispose", "=", "Aria", ".", "empty", ";", "}" ]
Mock for the resources handler. This is needed because loadResourcesHandler is called synchronously. This handler has only methods to get suggestions. These methods queue the latest suggestValue in order to replay it when the correct resources handler is loaded. @private
[ "Mock", "for", "the", "resources", "handler", ".", "This", "is", "needed", "because", "loadResourcesHandler", "is", "called", "synchronously", ".", "This", "handler", "has", "only", "methods", "to", "get", "suggestions", ".", "These", "methods", "queue", "the", "latest", "suggestValue", "in", "order", "to", "replay", "it", "when", "the", "correct", "resources", "handler", "is", "loaded", "." ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/html/controllers/Suggestions.js#L28-L42
train
ariatemplates/ariatemplates
src/aria/html/controllers/Suggestions.js
resourcesHandlerError
function resourcesHandlerError (args) { var scope = args.scope; // resources handler is not an AT class, no need to dispose scope._autoDisposeHandler = false; scope.$logError(scope.INVALID_RESOURCES_HANDLER, args.classpath); }
javascript
function resourcesHandlerError (args) { var scope = args.scope; // resources handler is not an AT class, no need to dispose scope._autoDisposeHandler = false; scope.$logError(scope.INVALID_RESOURCES_HANDLER, args.classpath); }
[ "function", "resourcesHandlerError", "(", "args", ")", "{", "var", "scope", "=", "args", ".", "scope", ";", "scope", ".", "_autoDisposeHandler", "=", "false", ";", "scope", ".", "$logError", "(", "scope", ".", "INVALID_RESOURCES_HANDLER", ",", "args", ".", "classpath", ")", ";", "}" ]
Error callback for Aria.load. @param {Object} args Callback arguments @private
[ "Error", "callback", "for", "Aria", ".", "load", "." ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/html/controllers/Suggestions.js#L49-L56
train
ariatemplates/ariatemplates
src/aria/html/controllers/Suggestions.js
resourcesHandlerLoaded
function resourcesHandlerLoaded (args) { var scope = args.scope, handler = Aria.getClassInstance(args.classpath); var pendingSuggestion = scope._resourcesHandler.pendingSuggestion; scope._resourcesHandler = handler; scope._autoDisposeHandler = true; if (pendingSuggestion) { if (pendingSuggestion.entry) { handler.getSuggestions(pendingSuggestion.entry, pendingSuggestion.callback); } else { handler.getAllSuggestions(pendingSuggestion.callback); } } }
javascript
function resourcesHandlerLoaded (args) { var scope = args.scope, handler = Aria.getClassInstance(args.classpath); var pendingSuggestion = scope._resourcesHandler.pendingSuggestion; scope._resourcesHandler = handler; scope._autoDisposeHandler = true; if (pendingSuggestion) { if (pendingSuggestion.entry) { handler.getSuggestions(pendingSuggestion.entry, pendingSuggestion.callback); } else { handler.getAllSuggestions(pendingSuggestion.callback); } } }
[ "function", "resourcesHandlerLoaded", "(", "args", ")", "{", "var", "scope", "=", "args", ".", "scope", ",", "handler", "=", "Aria", ".", "getClassInstance", "(", "args", ".", "classpath", ")", ";", "var", "pendingSuggestion", "=", "scope", ".", "_resourcesHandler", ".", "pendingSuggestion", ";", "scope", ".", "_resourcesHandler", "=", "handler", ";", "scope", ".", "_autoDisposeHandler", "=", "true", ";", "if", "(", "pendingSuggestion", ")", "{", "if", "(", "pendingSuggestion", ".", "entry", ")", "{", "handler", ".", "getSuggestions", "(", "pendingSuggestion", ".", "entry", ",", "pendingSuggestion", ".", "callback", ")", ";", "}", "else", "{", "handler", ".", "getAllSuggestions", "(", "pendingSuggestion", ".", "callback", ")", ";", "}", "}", "}" ]
Callback for Aria.load. Instantiate the ResourcesHandler class and set it on Suggestions controller @param {Object} args Callback arguments @private
[ "Callback", "for", "Aria", ".", "load", ".", "Instantiate", "the", "ResourcesHandler", "class", "and", "set", "it", "on", "Suggestions", "controller" ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/html/controllers/Suggestions.js#L63-L77
train
ariatemplates/ariatemplates
src/aria/html/controllers/Suggestions.js
delayLoading
function delayLoading (args) { ariaCoreTimer.addCallback({ fn : resourcesHandlerLoaded, args : args, scope : {}, delay : 12 }); }
javascript
function delayLoading (args) { ariaCoreTimer.addCallback({ fn : resourcesHandlerLoaded, args : args, scope : {}, delay : 12 }); }
[ "function", "delayLoading", "(", "args", ")", "{", "ariaCoreTimer", ".", "addCallback", "(", "{", "fn", ":", "resourcesHandlerLoaded", ",", "args", ":", "args", ",", "scope", ":", "{", "}", ",", "delay", ":", "12", "}", ")", ";", "}" ]
Intermediate callback to make sure that Aria.load is always async. @param {Object} args Callback arguments @private
[ "Intermediate", "callback", "to", "make", "sure", "that", "Aria", ".", "load", "is", "always", "async", "." ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/html/controllers/Suggestions.js#L84-L91
train
ariatemplates/ariatemplates
src/aria/html/controllers/Suggestions.js
loadResourcesHandler
function loadResourcesHandler (classpath, self) { var Handler = Aria.getClassRef(classpath); if (Handler) { return new Handler(); } else { var callbackArgs = { scope : self, classpath : classpath }; Aria.load({ classes : [classpath], oncomplete : { fn : delayLoading, args : callbackArgs }, onerror : { fn : resourcesHandlerError, args : callbackArgs } }); return new PromisedHandler(); } }
javascript
function loadResourcesHandler (classpath, self) { var Handler = Aria.getClassRef(classpath); if (Handler) { return new Handler(); } else { var callbackArgs = { scope : self, classpath : classpath }; Aria.load({ classes : [classpath], oncomplete : { fn : delayLoading, args : callbackArgs }, onerror : { fn : resourcesHandlerError, args : callbackArgs } }); return new PromisedHandler(); } }
[ "function", "loadResourcesHandler", "(", "classpath", ",", "self", ")", "{", "var", "Handler", "=", "Aria", ".", "getClassRef", "(", "classpath", ")", ";", "if", "(", "Handler", ")", "{", "return", "new", "Handler", "(", ")", ";", "}", "else", "{", "var", "callbackArgs", "=", "{", "scope", ":", "self", ",", "classpath", ":", "classpath", "}", ";", "Aria", ".", "load", "(", "{", "classes", ":", "[", "classpath", "]", ",", "oncomplete", ":", "{", "fn", ":", "delayLoading", ",", "args", ":", "callbackArgs", "}", ",", "onerror", ":", "{", "fn", ":", "resourcesHandlerError", ",", "args", ":", "callbackArgs", "}", "}", ")", ";", "return", "new", "PromisedHandler", "(", ")", ";", "}", "}" ]
Load and instantiate the resources handler. @param {String} classpath Resources Handler classpath @param {aria.html.controllers.Suggestions} self Suggestions controller instance @private
[ "Load", "and", "instantiate", "the", "resources", "handler", "." ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/html/controllers/Suggestions.js#L99-L124
train
ariatemplates/ariatemplates
src/aria/html/controllers/Suggestions.js
function (resourcesHandler) { if (ariaUtilsType.isString(resourcesHandler)) { resourcesHandler = loadResourcesHandler(resourcesHandler, this); this._autoDisposeHandler = true; } this._resourcesHandler = resourcesHandler; }
javascript
function (resourcesHandler) { if (ariaUtilsType.isString(resourcesHandler)) { resourcesHandler = loadResourcesHandler(resourcesHandler, this); this._autoDisposeHandler = true; } this._resourcesHandler = resourcesHandler; }
[ "function", "(", "resourcesHandler", ")", "{", "if", "(", "ariaUtilsType", ".", "isString", "(", "resourcesHandler", ")", ")", "{", "resourcesHandler", "=", "loadResourcesHandler", "(", "resourcesHandler", ",", "this", ")", ";", "this", ".", "_autoDisposeHandler", "=", "true", ";", "}", "this", ".", "_resourcesHandler", "=", "resourcesHandler", ";", "}" ]
Set the resourceHandler for this controller. If it's a classpath the class will be loaded and instantiated. @param {String|Object} resourcesHandler classpath or instance
[ "Set", "the", "resourceHandler", "for", "this", "controller", ".", "If", "it", "s", "a", "classpath", "the", "class", "will", "be", "loaded", "and", "instantiated", "." ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/html/controllers/Suggestions.js#L203-L209
train
ariatemplates/ariatemplates
src/aria/widgets/controllers/DateController.js
function (internalValue) { var report = new ariaWidgetsControllersReportsControllerReport(); if (internalValue == null) { report.ok = true; this._dataModel.jsDate = null; this._dataModel.displayText = ""; } else if (!ariaUtilsType.isDate(internalValue)) { report.ok = false; } else { // remove the time, so that comparisons with minValue and maxValue are // correct. internalValue = ariaUtilsDate.removeTime(internalValue); if (this._minValue && internalValue < this._minValue) { report.ok = false; report.errorMessages.push(this.getErrorMessage("minValue")); } else if (this._maxValue && internalValue > this._maxValue) { report.ok = false; report.errorMessages.push(this.getErrorMessage("maxValue")); } else { report.ok = true; this._dataModel.jsDate = internalValue; this._dataModel.displayText = ariaUtilsDate.format(internalValue, this._pattern); } } if (report.ok) { report.text = this._dataModel.displayText; report.value = this._dataModel.jsDate; } return report; }
javascript
function (internalValue) { var report = new ariaWidgetsControllersReportsControllerReport(); if (internalValue == null) { report.ok = true; this._dataModel.jsDate = null; this._dataModel.displayText = ""; } else if (!ariaUtilsType.isDate(internalValue)) { report.ok = false; } else { // remove the time, so that comparisons with minValue and maxValue are // correct. internalValue = ariaUtilsDate.removeTime(internalValue); if (this._minValue && internalValue < this._minValue) { report.ok = false; report.errorMessages.push(this.getErrorMessage("minValue")); } else if (this._maxValue && internalValue > this._maxValue) { report.ok = false; report.errorMessages.push(this.getErrorMessage("maxValue")); } else { report.ok = true; this._dataModel.jsDate = internalValue; this._dataModel.displayText = ariaUtilsDate.format(internalValue, this._pattern); } } if (report.ok) { report.text = this._dataModel.displayText; report.value = this._dataModel.jsDate; } return report; }
[ "function", "(", "internalValue", ")", "{", "var", "report", "=", "new", "ariaWidgetsControllersReportsControllerReport", "(", ")", ";", "if", "(", "internalValue", "==", "null", ")", "{", "report", ".", "ok", "=", "true", ";", "this", ".", "_dataModel", ".", "jsDate", "=", "null", ";", "this", ".", "_dataModel", ".", "displayText", "=", "\"\"", ";", "}", "else", "if", "(", "!", "ariaUtilsType", ".", "isDate", "(", "internalValue", ")", ")", "{", "report", ".", "ok", "=", "false", ";", "}", "else", "{", "internalValue", "=", "ariaUtilsDate", ".", "removeTime", "(", "internalValue", ")", ";", "if", "(", "this", ".", "_minValue", "&&", "internalValue", "<", "this", ".", "_minValue", ")", "{", "report", ".", "ok", "=", "false", ";", "report", ".", "errorMessages", ".", "push", "(", "this", ".", "getErrorMessage", "(", "\"minValue\"", ")", ")", ";", "}", "else", "if", "(", "this", ".", "_maxValue", "&&", "internalValue", ">", "this", ".", "_maxValue", ")", "{", "report", ".", "ok", "=", "false", ";", "report", ".", "errorMessages", ".", "push", "(", "this", ".", "getErrorMessage", "(", "\"maxValue\"", ")", ")", ";", "}", "else", "{", "report", ".", "ok", "=", "true", ";", "this", ".", "_dataModel", ".", "jsDate", "=", "internalValue", ";", "this", ".", "_dataModel", ".", "displayText", "=", "ariaUtilsDate", ".", "format", "(", "internalValue", ",", "this", ".", "_pattern", ")", ";", "}", "}", "if", "(", "report", ".", "ok", ")", "{", "report", ".", "text", "=", "this", ".", "_dataModel", ".", "displayText", ";", "report", ".", "value", "=", "this", ".", "_dataModel", ".", "jsDate", ";", "}", "return", "report", ";", "}" ]
override TextDataController.checkValue @param {String} internalValue - Internal value of to be validated @return {aria.widgets.controllers.reports.ControllerReport}
[ "override", "TextDataController", ".", "checkValue" ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/controllers/DateController.js#L136-L165
train
ariatemplates/ariatemplates
src/aria/core/Browser.js
function(receiver, name, state) { if (state == null) { state = true; } var flagName = this._buildFlagName(name); receiver[flagName] = state; return state; }
javascript
function(receiver, name, state) { if (state == null) { state = true; } var flagName = this._buildFlagName(name); receiver[flagName] = state; return state; }
[ "function", "(", "receiver", ",", "name", ",", "state", ")", "{", "if", "(", "state", "==", "null", ")", "{", "state", "=", "true", ";", "}", "var", "flagName", "=", "this", ".", "_buildFlagName", "(", "name", ")", ";", "receiver", "[", "flagName", "]", "=", "state", ";", "return", "state", ";", "}" ]
Sets the flag corresponding to the given name to the given state. <p> Setting a flag corresponds to assigning its state value to a property whose name is built with <em>_buildFlagName</em>. </p> <p> If no explicit state is given, true is assumed. </p> @param {Object} receiver The object receiving the resulting property @param {String} name The name of the flag @param {Boolean} state The state of the flag @return {Boolean} The final state of the flag. @private
[ "Sets", "the", "flag", "corresponding", "to", "the", "given", "name", "to", "the", "given", "state", "." ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/Browser.js#L706-L715
train
ariatemplates/ariatemplates
src/aria/core/Browser.js
function(source, destination) { // -------------------------------------------- arguments processing if (destination == null) { destination = this; } // ------------------------------------------------------ processing for (var key in source) { if (source.hasOwnProperty(key)) { destination[key] = source[key]; } } // ---------------------------------------------------------- return return destination; }
javascript
function(source, destination) { // -------------------------------------------- arguments processing if (destination == null) { destination = this; } // ------------------------------------------------------ processing for (var key in source) { if (source.hasOwnProperty(key)) { destination[key] = source[key]; } } // ---------------------------------------------------------- return return destination; }
[ "function", "(", "source", ",", "destination", ")", "{", "if", "(", "destination", "==", "null", ")", "{", "destination", "=", "this", ";", "}", "for", "(", "var", "key", "in", "source", ")", "{", "if", "(", "source", ".", "hasOwnProperty", "(", "key", ")", ")", "{", "destination", "[", "key", "]", "=", "source", "[", "key", "]", ";", "}", "}", "return", "destination", ";", "}" ]
Imports an object into another. <p> Own properties from given source are copied into given destination. </p> @param {Object} source The source object from which properties should be read. @param {Object} destination The object receiving the properties. Defaults to <em>this</em>. @return {Object} The destination object. @private
[ "Imports", "an", "object", "into", "another", "." ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/Browser.js#L769-L787
train
ariatemplates/ariatemplates
src/aria/core/Browser.js
function(userAgentWrapper) { // ----------------------------------------------- early termination var cacheKey = userAgentWrapper.ua.toLowerCase(); var values; if (this._propertiesCache.hasOwnProperty(cacheKey)) { values = this._propertiesCache[cacheKey]; } if (values != null) { return values; } // ----------------------------------------------------- computation values = this._computeProperties(userAgentWrapper); // ---------------------------------------------------------- output this._propertiesCache[cacheKey] = values; return values; }
javascript
function(userAgentWrapper) { // ----------------------------------------------- early termination var cacheKey = userAgentWrapper.ua.toLowerCase(); var values; if (this._propertiesCache.hasOwnProperty(cacheKey)) { values = this._propertiesCache[cacheKey]; } if (values != null) { return values; } // ----------------------------------------------------- computation values = this._computeProperties(userAgentWrapper); // ---------------------------------------------------------- output this._propertiesCache[cacheKey] = values; return values; }
[ "function", "(", "userAgentWrapper", ")", "{", "var", "cacheKey", "=", "userAgentWrapper", ".", "ua", ".", "toLowerCase", "(", ")", ";", "var", "values", ";", "if", "(", "this", ".", "_propertiesCache", ".", "hasOwnProperty", "(", "cacheKey", ")", ")", "{", "values", "=", "this", ".", "_propertiesCache", "[", "cacheKey", "]", ";", "}", "if", "(", "values", "!=", "null", ")", "{", "return", "values", ";", "}", "values", "=", "this", ".", "_computeProperties", "(", "userAgentWrapper", ")", ";", "this", ".", "_propertiesCache", "[", "cacheKey", "]", "=", "values", ";", "return", "values", ";", "}" ]
Returns properties corresponding to given user agent information. <p> The returned properties match a particular API: the one finally exposed by this class. Also, they benefit from a cache mechanism. </p> @param {Object} userAgentWrapper The user agent wrapper to use (see <em>aria.core.useragent.UserAgent.getUserAgentInfo</em>) @private
[ "Returns", "properties", "corresponding", "to", "given", "user", "agent", "information", "." ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/Browser.js#L800-L822
train
ariatemplates/ariatemplates
src/aria/core/Browser.js
function() { this._styleCache = {}; // ----------------------------------------------------------------- this.ua = ""; this.name = ""; this.version = ""; this.majorVersion = 0; /* BACKWARD-COMPATIBILITY-BEGIN (GitHub #1397) */ this._browserType = ""; this._browserVersion = ""; /* BACKWARD-COMPATIBILITY-END (GitHub #1397) */ this.isIE = false; /* BACKWARD-COMPATIBILITY-BEGIN (GitHub #1397) */ this._isIE6 = false; /* BACKWARD-COMPATIBILITY-END (GitHub #1397) */ this.isIE7 = false; this.isIE8 = false; this.isIE9 = false; this.isIE10 = false; this.isIE11 = false; this.isOldIE = false; this.isModernIE = false; this.isEdge = false; this.isFirefox = false; /* BACKWARD-COMPATIBILITY-BEGIN (GitHub #1397) */ this._isFF = false; /* BACKWARD-COMPATIBILITY-END (GitHub #1397) */ this.isChrome = false; this.isSafari = false; this.isOpera = false; this.isBlackBerryBrowser = false; this.isAndroidBrowser = false; this.isSafariMobile = false; this.isIEMobile = false; this.isOperaMobile = false; this.isOperaMini = false; this.isS60 = false; this.isPhantomJS = false; this.isOtherBrowser = false; this.isWebkit = false; this.isGecko = false; this.osName = ""; this.osVersion = ""; /* BACKWARD-COMPATIBILITY-BEGIN (GitHub #1397) */ this._environment = ""; /* BACKWARD-COMPATIBILITY-END (GitHub #1397) */ this.isWindows = false; this.isMac = false; this.isIOS = false; this.isAndroid = false; this.isWindowsPhone = false; this.isBlackBerry = false; this.isSymbian = false; this.isOtherOS = false; /* BACKWARD-COMPATIBILITY-BEGIN (GitHub #1397) */ this._isOtherMobile = false; /* BACKWARD-COMPATIBILITY-END (GitHub #1397) */ this.isMobileView = false; this.isDesktopView = false; /* BACKWARD-COMPATIBILITY-BEGIN (GitHub #1397) */ this._DesktopView = false; /* BACKWARD-COMPATIBILITY-END (GitHub #1397) */ /* BACKWARD-COMPATIBILITY-BEGIN (GitHub #1397) */ this._isPhone = false; this._isTablet = false; this._deviceName = ""; /* BACKWARD-COMPATIBILITY-END (GitHub #1397) */ }
javascript
function() { this._styleCache = {}; // ----------------------------------------------------------------- this.ua = ""; this.name = ""; this.version = ""; this.majorVersion = 0; /* BACKWARD-COMPATIBILITY-BEGIN (GitHub #1397) */ this._browserType = ""; this._browserVersion = ""; /* BACKWARD-COMPATIBILITY-END (GitHub #1397) */ this.isIE = false; /* BACKWARD-COMPATIBILITY-BEGIN (GitHub #1397) */ this._isIE6 = false; /* BACKWARD-COMPATIBILITY-END (GitHub #1397) */ this.isIE7 = false; this.isIE8 = false; this.isIE9 = false; this.isIE10 = false; this.isIE11 = false; this.isOldIE = false; this.isModernIE = false; this.isEdge = false; this.isFirefox = false; /* BACKWARD-COMPATIBILITY-BEGIN (GitHub #1397) */ this._isFF = false; /* BACKWARD-COMPATIBILITY-END (GitHub #1397) */ this.isChrome = false; this.isSafari = false; this.isOpera = false; this.isBlackBerryBrowser = false; this.isAndroidBrowser = false; this.isSafariMobile = false; this.isIEMobile = false; this.isOperaMobile = false; this.isOperaMini = false; this.isS60 = false; this.isPhantomJS = false; this.isOtherBrowser = false; this.isWebkit = false; this.isGecko = false; this.osName = ""; this.osVersion = ""; /* BACKWARD-COMPATIBILITY-BEGIN (GitHub #1397) */ this._environment = ""; /* BACKWARD-COMPATIBILITY-END (GitHub #1397) */ this.isWindows = false; this.isMac = false; this.isIOS = false; this.isAndroid = false; this.isWindowsPhone = false; this.isBlackBerry = false; this.isSymbian = false; this.isOtherOS = false; /* BACKWARD-COMPATIBILITY-BEGIN (GitHub #1397) */ this._isOtherMobile = false; /* BACKWARD-COMPATIBILITY-END (GitHub #1397) */ this.isMobileView = false; this.isDesktopView = false; /* BACKWARD-COMPATIBILITY-BEGIN (GitHub #1397) */ this._DesktopView = false; /* BACKWARD-COMPATIBILITY-END (GitHub #1397) */ /* BACKWARD-COMPATIBILITY-BEGIN (GitHub #1397) */ this._isPhone = false; this._isTablet = false; this._deviceName = ""; /* BACKWARD-COMPATIBILITY-END (GitHub #1397) */ }
[ "function", "(", ")", "{", "this", ".", "_styleCache", "=", "{", "}", ";", "this", ".", "ua", "=", "\"\"", ";", "this", ".", "name", "=", "\"\"", ";", "this", ".", "version", "=", "\"\"", ";", "this", ".", "majorVersion", "=", "0", ";", "this", ".", "_browserType", "=", "\"\"", ";", "this", ".", "_browserVersion", "=", "\"\"", ";", "this", ".", "isIE", "=", "false", ";", "this", ".", "_isIE6", "=", "false", ";", "this", ".", "isIE7", "=", "false", ";", "this", ".", "isIE8", "=", "false", ";", "this", ".", "isIE9", "=", "false", ";", "this", ".", "isIE10", "=", "false", ";", "this", ".", "isIE11", "=", "false", ";", "this", ".", "isOldIE", "=", "false", ";", "this", ".", "isModernIE", "=", "false", ";", "this", ".", "isEdge", "=", "false", ";", "this", ".", "isFirefox", "=", "false", ";", "this", ".", "_isFF", "=", "false", ";", "this", ".", "isChrome", "=", "false", ";", "this", ".", "isSafari", "=", "false", ";", "this", ".", "isOpera", "=", "false", ";", "this", ".", "isBlackBerryBrowser", "=", "false", ";", "this", ".", "isAndroidBrowser", "=", "false", ";", "this", ".", "isSafariMobile", "=", "false", ";", "this", ".", "isIEMobile", "=", "false", ";", "this", ".", "isOperaMobile", "=", "false", ";", "this", ".", "isOperaMini", "=", "false", ";", "this", ".", "isS60", "=", "false", ";", "this", ".", "isPhantomJS", "=", "false", ";", "this", ".", "isOtherBrowser", "=", "false", ";", "this", ".", "isWebkit", "=", "false", ";", "this", ".", "isGecko", "=", "false", ";", "this", ".", "osName", "=", "\"\"", ";", "this", ".", "osVersion", "=", "\"\"", ";", "this", ".", "_environment", "=", "\"\"", ";", "this", ".", "isWindows", "=", "false", ";", "this", ".", "isMac", "=", "false", ";", "this", ".", "isIOS", "=", "false", ";", "this", ".", "isAndroid", "=", "false", ";", "this", ".", "isWindowsPhone", "=", "false", ";", "this", ".", "isBlackBerry", "=", "false", ";", "this", ".", "isSymbian", "=", "false", ";", "this", ".", "isOtherOS", "=", "false", ";", "this", ".", "_isOtherMobile", "=", "false", ";", "this", ".", "isMobileView", "=", "false", ";", "this", ".", "isDesktopView", "=", "false", ";", "this", ".", "_DesktopView", "=", "false", ";", "this", ".", "_isPhone", "=", "false", ";", "this", ".", "_isTablet", "=", "false", ";", "this", ".", "_deviceName", "=", "\"\"", ";", "}" ]
Resets all properties to their default values. @private
[ "Resets", "all", "properties", "to", "their", "default", "values", "." ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/Browser.js#L1216-L1291
train
ariatemplates/ariatemplates
src/aria/core/Browser.js
function(userAgent) { var userAgentWrapper = UserAgent.getUserAgentInfo(userAgent); // ----------------------------------------- reset /apply properties this._resetProperties(); var properties = this._getProperties(userAgentWrapper); this._import(properties); /* BACKWARD-COMPATIBILITY-BEGIN (GitHub #1397) */ this.__ensureDeprecatedProperties(); /* BACKWARD-COMPATIBILITY-END (GitHub #1397) */ // ---------------------------------------------------------- return return userAgentWrapper; }
javascript
function(userAgent) { var userAgentWrapper = UserAgent.getUserAgentInfo(userAgent); // ----------------------------------------- reset /apply properties this._resetProperties(); var properties = this._getProperties(userAgentWrapper); this._import(properties); /* BACKWARD-COMPATIBILITY-BEGIN (GitHub #1397) */ this.__ensureDeprecatedProperties(); /* BACKWARD-COMPATIBILITY-END (GitHub #1397) */ // ---------------------------------------------------------- return return userAgentWrapper; }
[ "function", "(", "userAgent", ")", "{", "var", "userAgentWrapper", "=", "UserAgent", ".", "getUserAgentInfo", "(", "userAgent", ")", ";", "this", ".", "_resetProperties", "(", ")", ";", "var", "properties", "=", "this", ".", "_getProperties", "(", "userAgentWrapper", ")", ";", "this", ".", "_import", "(", "properties", ")", ";", "this", ".", "__ensureDeprecatedProperties", "(", ")", ";", "return", "userAgentWrapper", ";", "}" ]
Makes the class work with the given user agent. <p> If no user agent is given, current browser's one is taken. </p> <p> Not that providing a user agent different than the running browser's one will not make all functions return values corresponding to the browser associated to this custom user agent. Feature detection mechanism for instance will by nature always correspond to the running browser. </p> @param {String} userAgent The user agent to take into account in this class @return {Object} The user agent wrapper used to compute the properties (see <em>aria.core.useragent.UserAgent.getUserAgentInfo</em>)
[ "Makes", "the", "class", "work", "with", "the", "given", "user", "agent", "." ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/Browser.js#L1308-L1325
train
ariatemplates/ariatemplates
src/aria/core/Browser.js
function (property) { // ----------------------------------------------------------- cache if (this._styleCache.hasOwnProperty(property)) { return this._styleCache[property]; } // ------------------------------------------------------ processing // default if none of the actions below can find it var result = false; var prefixes = ['Moz', 'Webkit', 'Khtml', 'O', 'Ms']; var element = Aria.$window.document.documentElement; var style = element.style; // test standard property if (typeof style[property] === 'string') { result = true; } else { // capitalize var capitalizedProperty = property.charAt(0).toUpperCase() + property.slice(1); // test vendor specific properties for (var index = 0, length = prefixes.length; index < length; index++) { var prefix = prefixes[index]; var prefixed = prefix + capitalizedProperty; if (typeof style[prefixed] === 'string') { result = true; break; } } } // ---------------------------------------------------------- result this._styleCache[property] = result; return result; }
javascript
function (property) { // ----------------------------------------------------------- cache if (this._styleCache.hasOwnProperty(property)) { return this._styleCache[property]; } // ------------------------------------------------------ processing // default if none of the actions below can find it var result = false; var prefixes = ['Moz', 'Webkit', 'Khtml', 'O', 'Ms']; var element = Aria.$window.document.documentElement; var style = element.style; // test standard property if (typeof style[property] === 'string') { result = true; } else { // capitalize var capitalizedProperty = property.charAt(0).toUpperCase() + property.slice(1); // test vendor specific properties for (var index = 0, length = prefixes.length; index < length; index++) { var prefix = prefixes[index]; var prefixed = prefix + capitalizedProperty; if (typeof style[prefixed] === 'string') { result = true; break; } } } // ---------------------------------------------------------- result this._styleCache[property] = result; return result; }
[ "function", "(", "property", ")", "{", "if", "(", "this", ".", "_styleCache", ".", "hasOwnProperty", "(", "property", ")", ")", "{", "return", "this", ".", "_styleCache", "[", "property", "]", ";", "}", "var", "result", "=", "false", ";", "var", "prefixes", "=", "[", "'Moz'", ",", "'Webkit'", ",", "'Khtml'", ",", "'O'", ",", "'Ms'", "]", ";", "var", "element", "=", "Aria", ".", "$window", ".", "document", ".", "documentElement", ";", "var", "style", "=", "element", ".", "style", ";", "if", "(", "typeof", "style", "[", "property", "]", "===", "'string'", ")", "{", "result", "=", "true", ";", "}", "else", "{", "var", "capitalizedProperty", "=", "property", ".", "charAt", "(", "0", ")", ".", "toUpperCase", "(", ")", "+", "property", ".", "slice", "(", "1", ")", ";", "for", "(", "var", "index", "=", "0", ",", "length", "=", "prefixes", ".", "length", ";", "index", "<", "length", ";", "index", "++", ")", "{", "var", "prefix", "=", "prefixes", "[", "index", "]", ";", "var", "prefixed", "=", "prefix", "+", "capitalizedProperty", ";", "if", "(", "typeof", "style", "[", "prefixed", "]", "===", "'string'", ")", "{", "result", "=", "true", ";", "break", ";", "}", "}", "}", "this", ".", "_styleCache", "[", "property", "]", "=", "result", ";", "return", "result", ";", "}" ]
Check whether the given CSS property is supported by the browser or not. @param {String} property a CSS Property @return {Boolean} <em>true</em> if given style is supported, <em>false</em> otherwise. @private
[ "Check", "whether", "the", "given", "CSS", "property", "is", "supported", "by", "the", "browser", "or", "not", "." ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/Browser.js#L1364-L1404
train
ariatemplates/ariatemplates
src/aria/utils/resize/Resize.js
function (coord) { this.posX = coord.x; this.posY = coord.y; this._mouseInitialPosition = { left : coord.x, top : coord.y }; var element = this.getElement(true), movable, document = Aria.$window.document; // This will prevent text selection on IE on the element element.onselectstart = Aria.returnFalse; document.onselectstart = Aria.returnFalse; this._setElementStyle(element); this._setBoundary(); movable = this.getMovable(); if (movable) { // This will prevent text selection on IE on the movable movable.onselectstart = Aria.returnFalse; this._movableInitialGeometry = ariaUtilsDom.getGeometry(movable); this._movableGeometry = ariaUtilsJson.copy(this._movableInitialGeometry); this._baseMovableOffset = { left : this._movableGeometry.x - movable.offsetLeft, top : this._movableGeometry.y - movable.offsetTop, height : this._movableGeometry.height - movable.offsetHeight, width : this._movableGeometry.width - movable.offsetWidth }; this.$raiseEvent("beforeresize"); } }
javascript
function (coord) { this.posX = coord.x; this.posY = coord.y; this._mouseInitialPosition = { left : coord.x, top : coord.y }; var element = this.getElement(true), movable, document = Aria.$window.document; // This will prevent text selection on IE on the element element.onselectstart = Aria.returnFalse; document.onselectstart = Aria.returnFalse; this._setElementStyle(element); this._setBoundary(); movable = this.getMovable(); if (movable) { // This will prevent text selection on IE on the movable movable.onselectstart = Aria.returnFalse; this._movableInitialGeometry = ariaUtilsDom.getGeometry(movable); this._movableGeometry = ariaUtilsJson.copy(this._movableInitialGeometry); this._baseMovableOffset = { left : this._movableGeometry.x - movable.offsetLeft, top : this._movableGeometry.y - movable.offsetTop, height : this._movableGeometry.height - movable.offsetHeight, width : this._movableGeometry.width - movable.offsetWidth }; this.$raiseEvent("beforeresize"); } }
[ "function", "(", "coord", ")", "{", "this", ".", "posX", "=", "coord", ".", "x", ";", "this", ".", "posY", "=", "coord", ".", "y", ";", "this", ".", "_mouseInitialPosition", "=", "{", "left", ":", "coord", ".", "x", ",", "top", ":", "coord", ".", "y", "}", ";", "var", "element", "=", "this", ".", "getElement", "(", "true", ")", ",", "movable", ",", "document", "=", "Aria", ".", "$window", ".", "document", ";", "element", ".", "onselectstart", "=", "Aria", ".", "returnFalse", ";", "document", ".", "onselectstart", "=", "Aria", ".", "returnFalse", ";", "this", ".", "_setElementStyle", "(", "element", ")", ";", "this", ".", "_setBoundary", "(", ")", ";", "movable", "=", "this", ".", "getMovable", "(", ")", ";", "if", "(", "movable", ")", "{", "movable", ".", "onselectstart", "=", "Aria", ".", "returnFalse", ";", "this", ".", "_movableInitialGeometry", "=", "ariaUtilsDom", ".", "getGeometry", "(", "movable", ")", ";", "this", ".", "_movableGeometry", "=", "ariaUtilsJson", ".", "copy", "(", "this", ".", "_movableInitialGeometry", ")", ";", "this", ".", "_baseMovableOffset", "=", "{", "left", ":", "this", ".", "_movableGeometry", ".", "x", "-", "movable", ".", "offsetLeft", ",", "top", ":", "this", ".", "_movableGeometry", ".", "y", "-", "movable", ".", "offsetTop", ",", "height", ":", "this", ".", "_movableGeometry", ".", "height", "-", "movable", ".", "offsetHeight", ",", "width", ":", "this", ".", "_movableGeometry", ".", "width", "-", "movable", ".", "offsetWidth", "}", ";", "this", ".", "$raiseEvent", "(", "\"beforeresize\"", ")", ";", "}", "}" ]
Handle the resize start. Initialize some reference geometries and raise the beforeresize event @param {Object} coord Contains the x and y coordinates of the mouse when a drag start has been detected on resize handle
[ "Handle", "the", "resize", "start", ".", "Initialize", "some", "reference", "geometries", "and", "raise", "the", "beforeresize", "event" ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/resize/Resize.js#L63-L90
train
ariatemplates/ariatemplates
src/aria/utils/resize/Resize.js
function (evt) { var movable = this.getMovable(); if (movable && movable.style) { var mouseInitPos = this._mouseInitialPosition; var movableInitPos = this._movableInitialGeometry; var offsetX = this._vertical ? 0 : evt.clientX - mouseInitPos.left; var offsetY = this._horizontal ? 0 : evt.clientY - mouseInitPos.top; var geometry = ariaUtilsJson.copy(movableInitPos), dw, dh; geometry = this._resizeWitHandlers(geometry, this.cursor, offsetX, offsetY); var chkWidth = /sw-resize|nw-resize|w-resize/.test(this.cursor), chkHeight = /nw-resize|ne-resize|n-resize/.test(this.cursor), minWidth = geometry.width < this.minWidth, minHeight = geometry.height < this.minHeight; if (minWidth) { geometry.width = this.minWidth; } if (minHeight) { geometry.height = this.minHeight; } dw = this._movableGeometry.x + this._movableGeometry.width; dh = this._movableGeometry.y + this._movableGeometry.height; if (minWidth && chkWidth) { geometry.x = dw - this.minWidth; } if (minHeight && chkHeight) { geometry.y = dh - this.minHeight; } // for resizing the dialog movable.style.cursor = this.cursor; movable.style.top = (geometry.y - this._baseMovableOffset.top) + "px"; movable.style.left = (geometry.x - this._baseMovableOffset.left) + "px"; movable.style.height = (geometry.height - this._baseMovableOffset.height) + "px"; movable.style.width = (geometry.width - this._baseMovableOffset.width) + "px"; this.posY = mouseInitPos.top + geometry.y - movableInitPos.y; this.posX = mouseInitPos.left + geometry.x - movableInitPos.x; this._movableGeometry = geometry; this.$raiseEvent("resize"); } }
javascript
function (evt) { var movable = this.getMovable(); if (movable && movable.style) { var mouseInitPos = this._mouseInitialPosition; var movableInitPos = this._movableInitialGeometry; var offsetX = this._vertical ? 0 : evt.clientX - mouseInitPos.left; var offsetY = this._horizontal ? 0 : evt.clientY - mouseInitPos.top; var geometry = ariaUtilsJson.copy(movableInitPos), dw, dh; geometry = this._resizeWitHandlers(geometry, this.cursor, offsetX, offsetY); var chkWidth = /sw-resize|nw-resize|w-resize/.test(this.cursor), chkHeight = /nw-resize|ne-resize|n-resize/.test(this.cursor), minWidth = geometry.width < this.minWidth, minHeight = geometry.height < this.minHeight; if (minWidth) { geometry.width = this.minWidth; } if (minHeight) { geometry.height = this.minHeight; } dw = this._movableGeometry.x + this._movableGeometry.width; dh = this._movableGeometry.y + this._movableGeometry.height; if (minWidth && chkWidth) { geometry.x = dw - this.minWidth; } if (minHeight && chkHeight) { geometry.y = dh - this.minHeight; } // for resizing the dialog movable.style.cursor = this.cursor; movable.style.top = (geometry.y - this._baseMovableOffset.top) + "px"; movable.style.left = (geometry.x - this._baseMovableOffset.left) + "px"; movable.style.height = (geometry.height - this._baseMovableOffset.height) + "px"; movable.style.width = (geometry.width - this._baseMovableOffset.width) + "px"; this.posY = mouseInitPos.top + geometry.y - movableInitPos.y; this.posX = mouseInitPos.left + geometry.x - movableInitPos.x; this._movableGeometry = geometry; this.$raiseEvent("resize"); } }
[ "function", "(", "evt", ")", "{", "var", "movable", "=", "this", ".", "getMovable", "(", ")", ";", "if", "(", "movable", "&&", "movable", ".", "style", ")", "{", "var", "mouseInitPos", "=", "this", ".", "_mouseInitialPosition", ";", "var", "movableInitPos", "=", "this", ".", "_movableInitialGeometry", ";", "var", "offsetX", "=", "this", ".", "_vertical", "?", "0", ":", "evt", ".", "clientX", "-", "mouseInitPos", ".", "left", ";", "var", "offsetY", "=", "this", ".", "_horizontal", "?", "0", ":", "evt", ".", "clientY", "-", "mouseInitPos", ".", "top", ";", "var", "geometry", "=", "ariaUtilsJson", ".", "copy", "(", "movableInitPos", ")", ",", "dw", ",", "dh", ";", "geometry", "=", "this", ".", "_resizeWitHandlers", "(", "geometry", ",", "this", ".", "cursor", ",", "offsetX", ",", "offsetY", ")", ";", "var", "chkWidth", "=", "/", "sw-resize|nw-resize|w-resize", "/", ".", "test", "(", "this", ".", "cursor", ")", ",", "chkHeight", "=", "/", "nw-resize|ne-resize|n-resize", "/", ".", "test", "(", "this", ".", "cursor", ")", ",", "minWidth", "=", "geometry", ".", "width", "<", "this", ".", "minWidth", ",", "minHeight", "=", "geometry", ".", "height", "<", "this", ".", "minHeight", ";", "if", "(", "minWidth", ")", "{", "geometry", ".", "width", "=", "this", ".", "minWidth", ";", "}", "if", "(", "minHeight", ")", "{", "geometry", ".", "height", "=", "this", ".", "minHeight", ";", "}", "dw", "=", "this", ".", "_movableGeometry", ".", "x", "+", "this", ".", "_movableGeometry", ".", "width", ";", "dh", "=", "this", ".", "_movableGeometry", ".", "y", "+", "this", ".", "_movableGeometry", ".", "height", ";", "if", "(", "minWidth", "&&", "chkWidth", ")", "{", "geometry", ".", "x", "=", "dw", "-", "this", ".", "minWidth", ";", "}", "if", "(", "minHeight", "&&", "chkHeight", ")", "{", "geometry", ".", "y", "=", "dh", "-", "this", ".", "minHeight", ";", "}", "movable", ".", "style", ".", "cursor", "=", "this", ".", "cursor", ";", "movable", ".", "style", ".", "top", "=", "(", "geometry", ".", "y", "-", "this", ".", "_baseMovableOffset", ".", "top", ")", "+", "\"px\"", ";", "movable", ".", "style", ".", "left", "=", "(", "geometry", ".", "x", "-", "this", ".", "_baseMovableOffset", ".", "left", ")", "+", "\"px\"", ";", "movable", ".", "style", ".", "height", "=", "(", "geometry", ".", "height", "-", "this", ".", "_baseMovableOffset", ".", "height", ")", "+", "\"px\"", ";", "movable", ".", "style", ".", "width", "=", "(", "geometry", ".", "width", "-", "this", ".", "_baseMovableOffset", ".", "width", ")", "+", "\"px\"", ";", "this", ".", "posY", "=", "mouseInitPos", ".", "top", "+", "geometry", ".", "y", "-", "movableInitPos", ".", "y", ";", "this", ".", "posX", "=", "mouseInitPos", ".", "left", "+", "geometry", ".", "x", "-", "movableInitPos", ".", "x", ";", "this", ".", "_movableGeometry", "=", "geometry", ";", "this", ".", "$raiseEvent", "(", "\"resize\"", ")", ";", "}", "}" ]
Handle the mouse move during a drag by setting the correct position on the resize handle element. It will Raise the resize event @param {aria.DomEvent} evt
[ "Handle", "the", "mouse", "move", "during", "a", "drag", "by", "setting", "the", "correct", "position", "on", "the", "resize", "handle", "element", ".", "It", "will", "Raise", "the", "resize", "event" ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/resize/Resize.js#L96-L138
train
ariatemplates/ariatemplates
src/aria/utils/resize/Resize.js
function () { var element = this.getElement(); var document = Aria.$window.document; document.onselectstart = Aria.returnTrue; element.onselectstart = Aria.returnTrue; if (this.proxy && this.proxy.overlay) { element.style.top = (this._elementInitialPosition.top + this._movableGeometry.y - this._movableInitialGeometry.y) + "px"; element.style.left = (this._elementInitialPosition.left + this._movableGeometry.x - this._movableInitialGeometry.x) + "px"; element.style.height = (this._elementInitialPosition.height + this._movableGeometry.height - this._movableInitialGeometry.height) + "px"; element.style.width = (this._elementInitialPosition.width + this._movableGeometry.width - this._movableInitialGeometry.width) + "px"; this.proxy.$dispose(); this.proxy = null; } this.$raiseEvent("resizeend"); }
javascript
function () { var element = this.getElement(); var document = Aria.$window.document; document.onselectstart = Aria.returnTrue; element.onselectstart = Aria.returnTrue; if (this.proxy && this.proxy.overlay) { element.style.top = (this._elementInitialPosition.top + this._movableGeometry.y - this._movableInitialGeometry.y) + "px"; element.style.left = (this._elementInitialPosition.left + this._movableGeometry.x - this._movableInitialGeometry.x) + "px"; element.style.height = (this._elementInitialPosition.height + this._movableGeometry.height - this._movableInitialGeometry.height) + "px"; element.style.width = (this._elementInitialPosition.width + this._movableGeometry.width - this._movableInitialGeometry.width) + "px"; this.proxy.$dispose(); this.proxy = null; } this.$raiseEvent("resizeend"); }
[ "function", "(", ")", "{", "var", "element", "=", "this", ".", "getElement", "(", ")", ";", "var", "document", "=", "Aria", ".", "$window", ".", "document", ";", "document", ".", "onselectstart", "=", "Aria", ".", "returnTrue", ";", "element", ".", "onselectstart", "=", "Aria", ".", "returnTrue", ";", "if", "(", "this", ".", "proxy", "&&", "this", ".", "proxy", ".", "overlay", ")", "{", "element", ".", "style", ".", "top", "=", "(", "this", ".", "_elementInitialPosition", ".", "top", "+", "this", ".", "_movableGeometry", ".", "y", "-", "this", ".", "_movableInitialGeometry", ".", "y", ")", "+", "\"px\"", ";", "element", ".", "style", ".", "left", "=", "(", "this", ".", "_elementInitialPosition", ".", "left", "+", "this", ".", "_movableGeometry", ".", "x", "-", "this", ".", "_movableInitialGeometry", ".", "x", ")", "+", "\"px\"", ";", "element", ".", "style", ".", "height", "=", "(", "this", ".", "_elementInitialPosition", ".", "height", "+", "this", ".", "_movableGeometry", ".", "height", "-", "this", ".", "_movableInitialGeometry", ".", "height", ")", "+", "\"px\"", ";", "element", ".", "style", ".", "width", "=", "(", "this", ".", "_elementInitialPosition", ".", "width", "+", "this", ".", "_movableGeometry", ".", "width", "-", "this", ".", "_movableInitialGeometry", ".", "width", ")", "+", "\"px\"", ";", "this", ".", "proxy", ".", "$dispose", "(", ")", ";", "this", ".", "proxy", "=", "null", ";", "}", "this", ".", "$raiseEvent", "(", "\"resizeend\"", ")", ";", "}" ]
Handle the resize end. Apply the correct positioning to the height and width to the resizable element
[ "Handle", "the", "resize", "end", ".", "Apply", "the", "correct", "positioning", "to", "the", "height", "and", "width", "to", "the", "resizable", "element" ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/resize/Resize.js#L142-L162
train
ariatemplates/ariatemplates
src/aria/utils/resize/Resize.js
function (geometry, cursor, offX, offY) { var geometry = ariaUtilsJson.copy(geometry), trim = ariaUtilsString.trim; cursor = trim(cursor); var offsetX = geometry.width >= this.minWidth ? offX : 0; var offsetY = geometry.height >= this.minHeight ? offY : 0; switch (cursor) { case "n-resize" : geometry.y += offsetY; geometry.height -= offsetY; geometry = this._fitResizeBoundary(geometry); break; case "ne-resize" : geometry.y += offsetY; geometry.height -= offsetY; geometry.width += offsetX; geometry = this._fitResizeBoundary(geometry); break; case "nw-resize" : geometry.x += offsetX; geometry.y += offsetY; geometry.height -= offsetY; geometry.width -= offsetX; geometry = this._fitResizeBoundary(geometry); break; case "s-resize" : geometry.height += offsetY; geometry = this._fitResizeBoundary(geometry); break; case "se-resize" : geometry.height += offsetY; geometry.width += offsetX; geometry = this._fitResizeBoundary(geometry); break; case "sw-resize" : geometry.x += offsetX; geometry.height += offsetY; geometry.width -= offsetX; geometry = this._fitResizeBoundary(geometry); break; case "e-resize" : geometry.width += offsetX; geometry = this._fitResizeBoundary(geometry); break; case "w-resize" : geometry.x += offsetX; geometry.width -= offsetX; geometry = this._fitResizeBoundary(geometry); break; } return geometry; }
javascript
function (geometry, cursor, offX, offY) { var geometry = ariaUtilsJson.copy(geometry), trim = ariaUtilsString.trim; cursor = trim(cursor); var offsetX = geometry.width >= this.minWidth ? offX : 0; var offsetY = geometry.height >= this.minHeight ? offY : 0; switch (cursor) { case "n-resize" : geometry.y += offsetY; geometry.height -= offsetY; geometry = this._fitResizeBoundary(geometry); break; case "ne-resize" : geometry.y += offsetY; geometry.height -= offsetY; geometry.width += offsetX; geometry = this._fitResizeBoundary(geometry); break; case "nw-resize" : geometry.x += offsetX; geometry.y += offsetY; geometry.height -= offsetY; geometry.width -= offsetX; geometry = this._fitResizeBoundary(geometry); break; case "s-resize" : geometry.height += offsetY; geometry = this._fitResizeBoundary(geometry); break; case "se-resize" : geometry.height += offsetY; geometry.width += offsetX; geometry = this._fitResizeBoundary(geometry); break; case "sw-resize" : geometry.x += offsetX; geometry.height += offsetY; geometry.width -= offsetX; geometry = this._fitResizeBoundary(geometry); break; case "e-resize" : geometry.width += offsetX; geometry = this._fitResizeBoundary(geometry); break; case "w-resize" : geometry.x += offsetX; geometry.width -= offsetX; geometry = this._fitResizeBoundary(geometry); break; } return geometry; }
[ "function", "(", "geometry", ",", "cursor", ",", "offX", ",", "offY", ")", "{", "var", "geometry", "=", "ariaUtilsJson", ".", "copy", "(", "geometry", ")", ",", "trim", "=", "ariaUtilsString", ".", "trim", ";", "cursor", "=", "trim", "(", "cursor", ")", ";", "var", "offsetX", "=", "geometry", ".", "width", ">=", "this", ".", "minWidth", "?", "offX", ":", "0", ";", "var", "offsetY", "=", "geometry", ".", "height", ">=", "this", ".", "minHeight", "?", "offY", ":", "0", ";", "switch", "(", "cursor", ")", "{", "case", "\"n-resize\"", ":", "geometry", ".", "y", "+=", "offsetY", ";", "geometry", ".", "height", "-=", "offsetY", ";", "geometry", "=", "this", ".", "_fitResizeBoundary", "(", "geometry", ")", ";", "break", ";", "case", "\"ne-resize\"", ":", "geometry", ".", "y", "+=", "offsetY", ";", "geometry", ".", "height", "-=", "offsetY", ";", "geometry", ".", "width", "+=", "offsetX", ";", "geometry", "=", "this", ".", "_fitResizeBoundary", "(", "geometry", ")", ";", "break", ";", "case", "\"nw-resize\"", ":", "geometry", ".", "x", "+=", "offsetX", ";", "geometry", ".", "y", "+=", "offsetY", ";", "geometry", ".", "height", "-=", "offsetY", ";", "geometry", ".", "width", "-=", "offsetX", ";", "geometry", "=", "this", ".", "_fitResizeBoundary", "(", "geometry", ")", ";", "break", ";", "case", "\"s-resize\"", ":", "geometry", ".", "height", "+=", "offsetY", ";", "geometry", "=", "this", ".", "_fitResizeBoundary", "(", "geometry", ")", ";", "break", ";", "case", "\"se-resize\"", ":", "geometry", ".", "height", "+=", "offsetY", ";", "geometry", ".", "width", "+=", "offsetX", ";", "geometry", "=", "this", ".", "_fitResizeBoundary", "(", "geometry", ")", ";", "break", ";", "case", "\"sw-resize\"", ":", "geometry", ".", "x", "+=", "offsetX", ";", "geometry", ".", "height", "+=", "offsetY", ";", "geometry", ".", "width", "-=", "offsetX", ";", "geometry", "=", "this", ".", "_fitResizeBoundary", "(", "geometry", ")", ";", "break", ";", "case", "\"e-resize\"", ":", "geometry", ".", "width", "+=", "offsetX", ";", "geometry", "=", "this", ".", "_fitResizeBoundary", "(", "geometry", ")", ";", "break", ";", "case", "\"w-resize\"", ":", "geometry", ".", "x", "+=", "offsetX", ";", "geometry", ".", "width", "-=", "offsetX", ";", "geometry", "=", "this", ".", "_fitResizeBoundary", "(", "geometry", ")", ";", "break", ";", "}", "return", "geometry", ";", "}" ]
Calculates the top, left position and size of the resizable element and new position of resize cursor. @param {Object} geometry initial position and size of the resizable element @param {String} cursor css class of resizable handle element @param {Number} offX left position which resizable handle element has moved from its initial. @param {Number} offY top position which resizable handle element has moved from its initial. @return {Object} new position of resized and resize handle element
[ "Calculates", "the", "top", "left", "position", "and", "size", "of", "the", "resizable", "element", "and", "new", "position", "of", "resize", "cursor", "." ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/resize/Resize.js#L172-L223
train
ariatemplates/ariatemplates
src/aria/utils/resize/Resize.js
function (geometry) { var boundary = this._boundary; if (boundary) { var boundaryGeometry = boundary; if (boundary == ariaUtilsDom.VIEWPORT) { var viewportSize = ariaUtilsDom._getViewportSize(); boundaryGeometry = { x: 0, y: 0, width: viewportSize.width, height: viewportSize.height }; } var deltaLeft = geometry.x - boundaryGeometry.x; var deltaTop = geometry.y - boundaryGeometry.y; var deltaRight = boundaryGeometry.x + boundaryGeometry.width - geometry.x - geometry.width; var deltaBottom = boundaryGeometry.y + boundaryGeometry.height - geometry.y - geometry.height; if (deltaLeft < 0) { geometry.x -= deltaLeft; geometry.width += deltaLeft; } if (deltaTop < 0) { geometry.y -= deltaTop; geometry.height += deltaTop; } if (deltaRight < 0) { geometry.width += deltaRight; } if (deltaBottom < 0) { geometry.height += deltaBottom; } } return geometry; }
javascript
function (geometry) { var boundary = this._boundary; if (boundary) { var boundaryGeometry = boundary; if (boundary == ariaUtilsDom.VIEWPORT) { var viewportSize = ariaUtilsDom._getViewportSize(); boundaryGeometry = { x: 0, y: 0, width: viewportSize.width, height: viewportSize.height }; } var deltaLeft = geometry.x - boundaryGeometry.x; var deltaTop = geometry.y - boundaryGeometry.y; var deltaRight = boundaryGeometry.x + boundaryGeometry.width - geometry.x - geometry.width; var deltaBottom = boundaryGeometry.y + boundaryGeometry.height - geometry.y - geometry.height; if (deltaLeft < 0) { geometry.x -= deltaLeft; geometry.width += deltaLeft; } if (deltaTop < 0) { geometry.y -= deltaTop; geometry.height += deltaTop; } if (deltaRight < 0) { geometry.width += deltaRight; } if (deltaBottom < 0) { geometry.height += deltaBottom; } } return geometry; }
[ "function", "(", "geometry", ")", "{", "var", "boundary", "=", "this", ".", "_boundary", ";", "if", "(", "boundary", ")", "{", "var", "boundaryGeometry", "=", "boundary", ";", "if", "(", "boundary", "==", "ariaUtilsDom", ".", "VIEWPORT", ")", "{", "var", "viewportSize", "=", "ariaUtilsDom", ".", "_getViewportSize", "(", ")", ";", "boundaryGeometry", "=", "{", "x", ":", "0", ",", "y", ":", "0", ",", "width", ":", "viewportSize", ".", "width", ",", "height", ":", "viewportSize", ".", "height", "}", ";", "}", "var", "deltaLeft", "=", "geometry", ".", "x", "-", "boundaryGeometry", ".", "x", ";", "var", "deltaTop", "=", "geometry", ".", "y", "-", "boundaryGeometry", ".", "y", ";", "var", "deltaRight", "=", "boundaryGeometry", ".", "x", "+", "boundaryGeometry", ".", "width", "-", "geometry", ".", "x", "-", "geometry", ".", "width", ";", "var", "deltaBottom", "=", "boundaryGeometry", ".", "y", "+", "boundaryGeometry", ".", "height", "-", "geometry", ".", "y", "-", "geometry", ".", "height", ";", "if", "(", "deltaLeft", "<", "0", ")", "{", "geometry", ".", "x", "-=", "deltaLeft", ";", "geometry", ".", "width", "+=", "deltaLeft", ";", "}", "if", "(", "deltaTop", "<", "0", ")", "{", "geometry", ".", "y", "-=", "deltaTop", ";", "geometry", ".", "height", "+=", "deltaTop", ";", "}", "if", "(", "deltaRight", "<", "0", ")", "{", "geometry", ".", "width", "+=", "deltaRight", ";", "}", "if", "(", "deltaBottom", "<", "0", ")", "{", "geometry", ".", "height", "+=", "deltaBottom", ";", "}", "}", "return", "geometry", ";", "}" ]
Fits the resized element within viewport @param {aria.utils.DomBeans:Geometry} geometry @return {aria.utils.DomBeans:Geometry} fitted geometry
[ "Fits", "the", "resized", "element", "within", "viewport" ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/resize/Resize.js#L230-L263
train
ariatemplates/ariatemplates
src/aria/utils/resize/Resize.js
function (element) { var position = ariaUtilsDom.getOffset(element); position.width = element.offsetWidth; position.height = element.offsetHeight; var style = element.style; this._elementInitialPosition = position; style.position = "absolute"; style.left = position.left + "px"; style.top = position.top + "px"; style.height = position.height + "px"; style.width = position.width + "px"; }
javascript
function (element) { var position = ariaUtilsDom.getOffset(element); position.width = element.offsetWidth; position.height = element.offsetHeight; var style = element.style; this._elementInitialPosition = position; style.position = "absolute"; style.left = position.left + "px"; style.top = position.top + "px"; style.height = position.height + "px"; style.width = position.width + "px"; }
[ "function", "(", "element", ")", "{", "var", "position", "=", "ariaUtilsDom", ".", "getOffset", "(", "element", ")", ";", "position", ".", "width", "=", "element", ".", "offsetWidth", ";", "position", ".", "height", "=", "element", ".", "offsetHeight", ";", "var", "style", "=", "element", ".", "style", ";", "this", ".", "_elementInitialPosition", "=", "position", ";", "style", ".", "position", "=", "\"absolute\"", ";", "style", ".", "left", "=", "position", ".", "left", "+", "\"px\"", ";", "style", ".", "top", "=", "position", ".", "top", "+", "\"px\"", ";", "style", ".", "height", "=", "position", ".", "height", "+", "\"px\"", ";", "style", ".", "width", "=", "position", ".", "width", "+", "\"px\"", ";", "}" ]
Compute the initial position and initial size of the element and set its style properties @protected @param {HTMLElement} element
[ "Compute", "the", "initial", "position", "and", "initial", "size", "of", "the", "element", "and", "set", "its", "style", "properties" ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/resize/Resize.js#L269-L280
train
ariatemplates/ariatemplates
src/aria/tools/inspector/InspectorDisplayScript.js
function (event, template) { this.moduleCtrl.displayHighlight(template.templateCtxt.getContainerDiv()); this.data.overModuleCtrl = template.moduleCtrl; this.mouseOver(event); this._refreshModulesDisplay(); // prevent propagation event.stopPropagation(); }
javascript
function (event, template) { this.moduleCtrl.displayHighlight(template.templateCtxt.getContainerDiv()); this.data.overModuleCtrl = template.moduleCtrl; this.mouseOver(event); this._refreshModulesDisplay(); // prevent propagation event.stopPropagation(); }
[ "function", "(", "event", ",", "template", ")", "{", "this", ".", "moduleCtrl", ".", "displayHighlight", "(", "template", ".", "templateCtxt", ".", "getContainerDiv", "(", ")", ")", ";", "this", ".", "data", ".", "overModuleCtrl", "=", "template", ".", "moduleCtrl", ";", "this", ".", "mouseOver", "(", "event", ")", ";", "this", ".", "_refreshModulesDisplay", "(", ")", ";", "event", ".", "stopPropagation", "(", ")", ";", "}" ]
Highlight a template in the application on mouseover @param {Object} event @param {Object} template description
[ "Highlight", "a", "template", "in", "the", "application", "on", "mouseover" ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/tools/inspector/InspectorDisplayScript.js#L30-L37
train
ariatemplates/ariatemplates
src/aria/tools/inspector/InspectorDisplayScript.js
function (event, template) { // this.moduleCtrl.clearHighlight(); this.data.overModuleCtrl = null; this.mouseOut(event); this._refreshModulesDisplay(); // prevent propagation event.stopPropagation(); }
javascript
function (event, template) { // this.moduleCtrl.clearHighlight(); this.data.overModuleCtrl = null; this.mouseOut(event); this._refreshModulesDisplay(); // prevent propagation event.stopPropagation(); }
[ "function", "(", "event", ",", "template", ")", "{", "this", ".", "data", ".", "overModuleCtrl", "=", "null", ";", "this", ".", "mouseOut", "(", "event", ")", ";", "this", ".", "_refreshModulesDisplay", "(", ")", ";", "event", ".", "stopPropagation", "(", ")", ";", "}" ]
Remove highlight from a template link on mouseout @param {Object} event
[ "Remove", "highlight", "from", "a", "template", "link", "on", "mouseout" ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/tools/inspector/InspectorDisplayScript.js#L43-L50
train
ariatemplates/ariatemplates
src/aria/tools/inspector/InspectorDisplayScript.js
function (event, module) { this.data.overTemplates = module.outerTemplateCtxts; this.mouseOver(event); this._refreshTemplatesDisplay(); // prevent propagation event.stopPropagation(); }
javascript
function (event, module) { this.data.overTemplates = module.outerTemplateCtxts; this.mouseOver(event); this._refreshTemplatesDisplay(); // prevent propagation event.stopPropagation(); }
[ "function", "(", "event", ",", "module", ")", "{", "this", ".", "data", ".", "overTemplates", "=", "module", ".", "outerTemplateCtxts", ";", "this", ".", "mouseOver", "(", "event", ")", ";", "this", ".", "_refreshTemplatesDisplay", "(", ")", ";", "event", ".", "stopPropagation", "(", ")", ";", "}" ]
Highlight the template associated with a module @param {Object} event @param {Object} module description
[ "Highlight", "the", "template", "associated", "with", "a", "module" ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/tools/inspector/InspectorDisplayScript.js#L57-L63
train
ariatemplates/ariatemplates
src/aria/core/Cache.js
function (classpath) { var basePath = Aria.getLogicalPath(classpath); for (var i = 0, l = atExtensions.length; i < l; i++) { try { var logicalPath = basePath + atExtensions[i]; var cacheItem = require.cache[require.resolve(logicalPath)]; if (cacheItem) { return logicalPath; } } catch (e) { // require.resolve can throw an exception in node.js if the file does not exist // simply try other extensions in that case } } // it may be the classpath of a resource (which would not appear in the require cache): var resMgr = aria.core.ResMgr; if (resMgr) { return resMgr.getResourceLogicalPath(basePath); } }
javascript
function (classpath) { var basePath = Aria.getLogicalPath(classpath); for (var i = 0, l = atExtensions.length; i < l; i++) { try { var logicalPath = basePath + atExtensions[i]; var cacheItem = require.cache[require.resolve(logicalPath)]; if (cacheItem) { return logicalPath; } } catch (e) { // require.resolve can throw an exception in node.js if the file does not exist // simply try other extensions in that case } } // it may be the classpath of a resource (which would not appear in the require cache): var resMgr = aria.core.ResMgr; if (resMgr) { return resMgr.getResourceLogicalPath(basePath); } }
[ "function", "(", "classpath", ")", "{", "var", "basePath", "=", "Aria", ".", "getLogicalPath", "(", "classpath", ")", ";", "for", "(", "var", "i", "=", "0", ",", "l", "=", "atExtensions", ".", "length", ";", "i", "<", "l", ";", "i", "++", ")", "{", "try", "{", "var", "logicalPath", "=", "basePath", "+", "atExtensions", "[", "i", "]", ";", "var", "cacheItem", "=", "require", ".", "cache", "[", "require", ".", "resolve", "(", "logicalPath", ")", "]", ";", "if", "(", "cacheItem", ")", "{", "return", "logicalPath", ";", "}", "}", "catch", "(", "e", ")", "{", "}", "}", "var", "resMgr", "=", "aria", ".", "core", ".", "ResMgr", ";", "if", "(", "resMgr", ")", "{", "return", "resMgr", ".", "getResourceLogicalPath", "(", "basePath", ")", ";", "}", "}" ]
Get the logical filename from the classpath. Returns null if the classpath is not inside the cache. @param {String} classpath e.g x.y.MyClass @return {String} logical path e.g x/y/MyClass.tpl
[ "Get", "the", "logical", "filename", "from", "the", "classpath", ".", "Returns", "null", "if", "the", "classpath", "is", "not", "inside", "the", "cache", "." ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/Cache.js#L118-L137
train
ariatemplates/ariatemplates
src/aria/utils/Dom.js
function (id) { if (ariaCoreBrowser.isIE7) { this.getElementById = function (id) { var document = Aria.$window.document; var el = document.getElementById(id); if (el) { // If id match, return element if (el.getAttribute("id") == id) { return el; } else { for (var elem in document.all) { if (elem.id == id) { return elem; } } } } return null; }; } else { this.getElementById = function (id) { var document = Aria.$window.document; return document.getElementById(id); }; } return this.getElementById(id); }
javascript
function (id) { if (ariaCoreBrowser.isIE7) { this.getElementById = function (id) { var document = Aria.$window.document; var el = document.getElementById(id); if (el) { // If id match, return element if (el.getAttribute("id") == id) { return el; } else { for (var elem in document.all) { if (elem.id == id) { return elem; } } } } return null; }; } else { this.getElementById = function (id) { var document = Aria.$window.document; return document.getElementById(id); }; } return this.getElementById(id); }
[ "function", "(", "id", ")", "{", "if", "(", "ariaCoreBrowser", ".", "isIE7", ")", "{", "this", ".", "getElementById", "=", "function", "(", "id", ")", "{", "var", "document", "=", "Aria", ".", "$window", ".", "document", ";", "var", "el", "=", "document", ".", "getElementById", "(", "id", ")", ";", "if", "(", "el", ")", "{", "if", "(", "el", ".", "getAttribute", "(", "\"id\"", ")", "==", "id", ")", "{", "return", "el", ";", "}", "else", "{", "for", "(", "var", "elem", "in", "document", ".", "all", ")", "{", "if", "(", "elem", ".", "id", "==", "id", ")", "{", "return", "elem", ";", "}", "}", "}", "}", "return", "null", ";", "}", ";", "}", "else", "{", "this", ".", "getElementById", "=", "function", "(", "id", ")", "{", "var", "document", "=", "Aria", ".", "$window", ".", "document", ";", "return", "document", ".", "getElementById", "(", "id", ")", ";", "}", ";", "}", "return", "this", ".", "getElementById", "(", "id", ")", ";", "}" ]
To be used instead of document.getElementById because IE7 does not retrieve correctly the elements in some cases @param {String} id the 'id' parameter of the element to find @return {HTMLElement}
[ "To", "be", "used", "instead", "of", "document", ".", "getElementById", "because", "IE7", "does", "not", "retrieve", "correctly", "the", "elements", "in", "some", "cases" ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Dom.js#L45-L71
train
ariatemplates/ariatemplates
src/aria/utils/Dom.js
function (domElt, count) { if (count == null) { count = 1; } while (domElt && count > 0) { domElt = domElt.nextSibling; if (domElt && domElt.nodeType == 1) { count--; } } return domElt; }
javascript
function (domElt, count) { if (count == null) { count = 1; } while (domElt && count > 0) { domElt = domElt.nextSibling; if (domElt && domElt.nodeType == 1) { count--; } } return domElt; }
[ "function", "(", "domElt", ",", "count", ")", "{", "if", "(", "count", "==", "null", ")", "{", "count", "=", "1", ";", "}", "while", "(", "domElt", "&&", "count", ">", "0", ")", "{", "domElt", "=", "domElt", ".", "nextSibling", ";", "if", "(", "domElt", "&&", "domElt", ".", "nodeType", "==", "1", ")", "{", "count", "--", ";", "}", "}", "return", "domElt", ";", "}" ]
Get one of the elements in the DOM which follows the given DOM element. @param {HTMLElement} domElt reference DOM element @param {Number} count [optional, default: 1], number of the following DOM element (1 for the immediately following DOM element) @return {HTMLElement}
[ "Get", "one", "of", "the", "elements", "in", "the", "DOM", "which", "follows", "the", "given", "DOM", "element", "." ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Dom.js#L80-L91
train
ariatemplates/ariatemplates
src/aria/utils/Dom.js
function (domElt, count) { if (count == null) { count = 1; } while (domElt && count > 0) { domElt = domElt.previousSibling; if (domElt && domElt.nodeType == 1) { count--; } } return domElt; }
javascript
function (domElt, count) { if (count == null) { count = 1; } while (domElt && count > 0) { domElt = domElt.previousSibling; if (domElt && domElt.nodeType == 1) { count--; } } return domElt; }
[ "function", "(", "domElt", ",", "count", ")", "{", "if", "(", "count", "==", "null", ")", "{", "count", "=", "1", ";", "}", "while", "(", "domElt", "&&", "count", ">", "0", ")", "{", "domElt", "=", "domElt", ".", "previousSibling", ";", "if", "(", "domElt", "&&", "domElt", ".", "nodeType", "==", "1", ")", "{", "count", "--", ";", "}", "}", "return", "domElt", ";", "}" ]
Get one of the elements in the DOM which precedes the given DOM element. @param {HTMLElement} domElt reference DOM element @param {Number} count [optional, default: 1], number of the preceding DOM element (1 for the immediately preceding DOM element)
[ "Get", "one", "of", "the", "elements", "in", "the", "DOM", "which", "precedes", "the", "given", "DOM", "element", "." ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Dom.js#L99-L110
train
ariatemplates/ariatemplates
src/aria/utils/Dom.js
function (parentNode, index, reverse) { if (!parentNode) { return null; } var childNodes = parentNode.childNodes, count = 0, l = childNodes.length; for (var i = (reverse) ? l - 1 : 0; (reverse) ? i >= 0 : i < l; (reverse) ? i-- : i++) { if (childNodes[i].nodeType == 1) { // this is an element if (count == index) { return childNodes[i]; } count++; } } return null; }
javascript
function (parentNode, index, reverse) { if (!parentNode) { return null; } var childNodes = parentNode.childNodes, count = 0, l = childNodes.length; for (var i = (reverse) ? l - 1 : 0; (reverse) ? i >= 0 : i < l; (reverse) ? i-- : i++) { if (childNodes[i].nodeType == 1) { // this is an element if (count == index) { return childNodes[i]; } count++; } } return null; }
[ "function", "(", "parentNode", ",", "index", ",", "reverse", ")", "{", "if", "(", "!", "parentNode", ")", "{", "return", "null", ";", "}", "var", "childNodes", "=", "parentNode", ".", "childNodes", ",", "count", "=", "0", ",", "l", "=", "childNodes", ".", "length", ";", "for", "(", "var", "i", "=", "(", "reverse", ")", "?", "l", "-", "1", ":", "0", ";", "(", "reverse", ")", "?", "i", ">=", "0", ":", "i", "<", "l", ";", "(", "reverse", ")", "?", "i", "--", ":", "i", "++", ")", "{", "if", "(", "childNodes", "[", "i", "]", ".", "nodeType", "==", "1", ")", "{", "if", "(", "count", "==", "index", ")", "{", "return", "childNodes", "[", "i", "]", ";", "}", "count", "++", ";", "}", "}", "return", "null", ";", "}" ]
Used to retrieve a node element of type ELEMENT @param {HTMLElement} parentNode @param {Integer} index the expected index in the list (0=first) @param {Boolean} reverse true to start from the last child with reverse order @return {HTMLElement} the dom elt or null if not found @public
[ "Used", "to", "retrieve", "a", "node", "element", "of", "type", "ELEMENT" ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Dom.js#L120-L135
train
ariatemplates/ariatemplates
src/aria/utils/Dom.js
function (idOrElt, newHTML) { // PROFILING // var msr1 = this.$startMeasure("ReplaceHTML"); var domElt = idOrElt; if (typeof(domElt) == "string") { domElt = this.getElementById(domElt); } if (domElt) { if ((ariaCoreBrowser.isIE7 || ariaCoreBrowser.isIE8) && aria.utils && aria.utils.Delegate) { try { var activeElement = Aria.$window.document.activeElement; if (activeElement && this.isAncestor(activeElement, domElt)) { // On IE 7-8, there is an issue after removing from the DOM a focused element. // We detect it here so that next time there is a need to focus an element, we focus the // body first (which is the work-around for IE 7-8) aria.utils.Delegate.ieRemovingFocusedElement(); } } catch (e) { // on (real) IE8, an "Unspecified error" can be raised when trying to read // Aria.$window.document.activeElement // It happens when executing the following test: test.aria.utils.cfgframe.AriaWindowTest // It does not happen with IE 11 in IE8 mode. } } // PROFILING // var msr2 = this.$startMeasure("RemoveHTML"); // TODO: check HTML for security (no script ...) try { domElt.innerHTML = ""; // this makes IE run faster (!) // PROFILING // this.$stopMeasure(msr2); domElt.innerHTML = newHTML; } catch (ex) { // PTR 04429212: // IE does not support setting the innerHTML property of tbody, tfoot, thead or tr elements // directly. We use a simple work-around: // create a complete table, get the HTML element and insert it in the DOM var newDomElt = this._createTableElement(domElt.tagName, newHTML, domElt.ownerDocument); if (newDomElt) { this.replaceDomElement(domElt, newDomElt); this.copyAttributes(domElt, newDomElt); domElt = newDomElt; } else { // propagate the exception throw ex; } } // PROFILING // var msr3 = this.$startMeasure("contentchange"); // use the delegate manager to forward a fake event if (aria.utils && aria.utils.Delegate) { aria.utils.Delegate.delegate(aria.DomEvent.getFakeEvent('contentchange', domElt)); } // PROFILING // this.$stopMeasure(msr3); } else { this.$logError(this.DIV_NOT_FOUND, [idOrElt]); return null; } // PROFILING // this.$stopMeasure(msr1); return domElt; }
javascript
function (idOrElt, newHTML) { // PROFILING // var msr1 = this.$startMeasure("ReplaceHTML"); var domElt = idOrElt; if (typeof(domElt) == "string") { domElt = this.getElementById(domElt); } if (domElt) { if ((ariaCoreBrowser.isIE7 || ariaCoreBrowser.isIE8) && aria.utils && aria.utils.Delegate) { try { var activeElement = Aria.$window.document.activeElement; if (activeElement && this.isAncestor(activeElement, domElt)) { // On IE 7-8, there is an issue after removing from the DOM a focused element. // We detect it here so that next time there is a need to focus an element, we focus the // body first (which is the work-around for IE 7-8) aria.utils.Delegate.ieRemovingFocusedElement(); } } catch (e) { // on (real) IE8, an "Unspecified error" can be raised when trying to read // Aria.$window.document.activeElement // It happens when executing the following test: test.aria.utils.cfgframe.AriaWindowTest // It does not happen with IE 11 in IE8 mode. } } // PROFILING // var msr2 = this.$startMeasure("RemoveHTML"); // TODO: check HTML for security (no script ...) try { domElt.innerHTML = ""; // this makes IE run faster (!) // PROFILING // this.$stopMeasure(msr2); domElt.innerHTML = newHTML; } catch (ex) { // PTR 04429212: // IE does not support setting the innerHTML property of tbody, tfoot, thead or tr elements // directly. We use a simple work-around: // create a complete table, get the HTML element and insert it in the DOM var newDomElt = this._createTableElement(domElt.tagName, newHTML, domElt.ownerDocument); if (newDomElt) { this.replaceDomElement(domElt, newDomElt); this.copyAttributes(domElt, newDomElt); domElt = newDomElt; } else { // propagate the exception throw ex; } } // PROFILING // var msr3 = this.$startMeasure("contentchange"); // use the delegate manager to forward a fake event if (aria.utils && aria.utils.Delegate) { aria.utils.Delegate.delegate(aria.DomEvent.getFakeEvent('contentchange', domElt)); } // PROFILING // this.$stopMeasure(msr3); } else { this.$logError(this.DIV_NOT_FOUND, [idOrElt]); return null; } // PROFILING // this.$stopMeasure(msr1); return domElt; }
[ "function", "(", "idOrElt", ",", "newHTML", ")", "{", "var", "domElt", "=", "idOrElt", ";", "if", "(", "typeof", "(", "domElt", ")", "==", "\"string\"", ")", "{", "domElt", "=", "this", ".", "getElementById", "(", "domElt", ")", ";", "}", "if", "(", "domElt", ")", "{", "if", "(", "(", "ariaCoreBrowser", ".", "isIE7", "||", "ariaCoreBrowser", ".", "isIE8", ")", "&&", "aria", ".", "utils", "&&", "aria", ".", "utils", ".", "Delegate", ")", "{", "try", "{", "var", "activeElement", "=", "Aria", ".", "$window", ".", "document", ".", "activeElement", ";", "if", "(", "activeElement", "&&", "this", ".", "isAncestor", "(", "activeElement", ",", "domElt", ")", ")", "{", "aria", ".", "utils", ".", "Delegate", ".", "ieRemovingFocusedElement", "(", ")", ";", "}", "}", "catch", "(", "e", ")", "{", "}", "}", "try", "{", "domElt", ".", "innerHTML", "=", "\"\"", ";", "domElt", ".", "innerHTML", "=", "newHTML", ";", "}", "catch", "(", "ex", ")", "{", "var", "newDomElt", "=", "this", ".", "_createTableElement", "(", "domElt", ".", "tagName", ",", "newHTML", ",", "domElt", ".", "ownerDocument", ")", ";", "if", "(", "newDomElt", ")", "{", "this", ".", "replaceDomElement", "(", "domElt", ",", "newDomElt", ")", ";", "this", ".", "copyAttributes", "(", "domElt", ",", "newDomElt", ")", ";", "domElt", "=", "newDomElt", ";", "}", "else", "{", "throw", "ex", ";", "}", "}", "if", "(", "aria", ".", "utils", "&&", "aria", ".", "utils", ".", "Delegate", ")", "{", "aria", ".", "utils", ".", "Delegate", ".", "delegate", "(", "aria", ".", "DomEvent", ".", "getFakeEvent", "(", "'contentchange'", ",", "domElt", ")", ")", ";", "}", "}", "else", "{", "this", ".", "$logError", "(", "this", ".", "DIV_NOT_FOUND", ",", "[", "idOrElt", "]", ")", ";", "return", "null", ";", "}", "return", "domElt", ";", "}" ]
Replace the HTML contained in an element by another piece of HTML. @param {aria.templates.CfgBeans:Div} idOrElt div whose content have to be replaced @param {String} newHTML html to set @return {Object} Reference to the html element, or null if the element was not found in the DOM. If the element was not found in the DOM, the DIV_NOT_FOUND error is also logged. Note that in IE, in tables, the returned domElt can be different from the one given as a parameter.
[ "Replace", "the", "HTML", "contained", "in", "an", "element", "by", "another", "piece", "of", "HTML", "." ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Dom.js#L218-L275
train
ariatemplates/ariatemplates
src/aria/utils/Dom.js
function (oldElt, newElt) { var parentNode = oldElt.parentNode; parentNode.insertBefore(newElt, oldElt); parentNode.removeChild(oldElt); }
javascript
function (oldElt, newElt) { var parentNode = oldElt.parentNode; parentNode.insertBefore(newElt, oldElt); parentNode.removeChild(oldElt); }
[ "function", "(", "oldElt", ",", "newElt", ")", "{", "var", "parentNode", "=", "oldElt", ".", "parentNode", ";", "parentNode", ".", "insertBefore", "(", "newElt", ",", "oldElt", ")", ";", "parentNode", ".", "removeChild", "(", "oldElt", ")", ";", "}" ]
Simple utility method which replaces a dom element by another. @param {HTMLElement} oldElt @param {HTMLElement} newElt
[ "Simple", "utility", "method", "which", "replaces", "a", "dom", "element", "by", "another", "." ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Dom.js#L311-L315
train
ariatemplates/ariatemplates
src/aria/utils/Dom.js
function (domElt, where, html) { if (Aria.$window.document.body.insertAdjacentHTML) { this.insertAdjacentHTML = function (domElt, where, html) { // PROFILING // var msr = this.$startMeasure("insertAdjacentHTML"); // IE, Chrome, Safari, Opera // simply use insertAdjacentHTML try { domElt.insertAdjacentHTML(where, html); } catch (ex) { // insertAdjacentHTML can fail in IE with tbody, tfoot, thead or tr elements // We use a simple work-around: create a complete table, get the HTML element and insert it in // the DOM var containerElt; var newDomElt; if (where == "afterBegin" || where == "beforeEnd") { containerElt = domElt; } else if (where == "beforeBegin" || where == "afterEnd") { containerElt = domElt.parentNode; } else { this.$logError(this.INSERT_ADJACENT_INVALID_POSITION, [where]); return; } newDomElt = this._createTableElement(containerElt.tagName, html, domElt.ownerDocument); if (newDomElt) { var previousChild = newDomElt.lastChild; // now let's move the html content to the right place // first put lastChild at the right place, then, move the remaining children if (previousChild) { this.insertAdjacentElement(domElt, where, previousChild); var curChild = newDomElt.lastChild; while (curChild) { containerElt.insertBefore(curChild, previousChild); previousChild = curChild; curChild = newDomElt.lastChild; } } } else { // propagate the exception throw ex; } } // PROFILING // this.$stopMeasure(msr); }; } else { this.insertAdjacentHTML = function (domElt, where, html) { // PROFILING // var msr = this.$startMeasure("insertAdjacentHTML"); // Firefox // Note that this solution could work as well with Chrome, Safari and Opera var document = domElt.ownerDocument; var range = document.createRange(); if (where == "beforeBegin" || where == "afterEnd") { range.selectNode(domElt); } else { range.selectNodeContents(domElt); } var fragment = range.createContextualFragment(html); this.insertAdjacentElement(domElt, where, fragment); range.detach(); // PROFILING // this.$stopMeasure(msr); }; } this.insertAdjacentHTML(domElt, where, html); }
javascript
function (domElt, where, html) { if (Aria.$window.document.body.insertAdjacentHTML) { this.insertAdjacentHTML = function (domElt, where, html) { // PROFILING // var msr = this.$startMeasure("insertAdjacentHTML"); // IE, Chrome, Safari, Opera // simply use insertAdjacentHTML try { domElt.insertAdjacentHTML(where, html); } catch (ex) { // insertAdjacentHTML can fail in IE with tbody, tfoot, thead or tr elements // We use a simple work-around: create a complete table, get the HTML element and insert it in // the DOM var containerElt; var newDomElt; if (where == "afterBegin" || where == "beforeEnd") { containerElt = domElt; } else if (where == "beforeBegin" || where == "afterEnd") { containerElt = domElt.parentNode; } else { this.$logError(this.INSERT_ADJACENT_INVALID_POSITION, [where]); return; } newDomElt = this._createTableElement(containerElt.tagName, html, domElt.ownerDocument); if (newDomElt) { var previousChild = newDomElt.lastChild; // now let's move the html content to the right place // first put lastChild at the right place, then, move the remaining children if (previousChild) { this.insertAdjacentElement(domElt, where, previousChild); var curChild = newDomElt.lastChild; while (curChild) { containerElt.insertBefore(curChild, previousChild); previousChild = curChild; curChild = newDomElt.lastChild; } } } else { // propagate the exception throw ex; } } // PROFILING // this.$stopMeasure(msr); }; } else { this.insertAdjacentHTML = function (domElt, where, html) { // PROFILING // var msr = this.$startMeasure("insertAdjacentHTML"); // Firefox // Note that this solution could work as well with Chrome, Safari and Opera var document = domElt.ownerDocument; var range = document.createRange(); if (where == "beforeBegin" || where == "afterEnd") { range.selectNode(domElt); } else { range.selectNodeContents(domElt); } var fragment = range.createContextualFragment(html); this.insertAdjacentElement(domElt, where, fragment); range.detach(); // PROFILING // this.$stopMeasure(msr); }; } this.insertAdjacentHTML(domElt, where, html); }
[ "function", "(", "domElt", ",", "where", ",", "html", ")", "{", "if", "(", "Aria", ".", "$window", ".", "document", ".", "body", ".", "insertAdjacentHTML", ")", "{", "this", ".", "insertAdjacentHTML", "=", "function", "(", "domElt", ",", "where", ",", "html", ")", "{", "try", "{", "domElt", ".", "insertAdjacentHTML", "(", "where", ",", "html", ")", ";", "}", "catch", "(", "ex", ")", "{", "var", "containerElt", ";", "var", "newDomElt", ";", "if", "(", "where", "==", "\"afterBegin\"", "||", "where", "==", "\"beforeEnd\"", ")", "{", "containerElt", "=", "domElt", ";", "}", "else", "if", "(", "where", "==", "\"beforeBegin\"", "||", "where", "==", "\"afterEnd\"", ")", "{", "containerElt", "=", "domElt", ".", "parentNode", ";", "}", "else", "{", "this", ".", "$logError", "(", "this", ".", "INSERT_ADJACENT_INVALID_POSITION", ",", "[", "where", "]", ")", ";", "return", ";", "}", "newDomElt", "=", "this", ".", "_createTableElement", "(", "containerElt", ".", "tagName", ",", "html", ",", "domElt", ".", "ownerDocument", ")", ";", "if", "(", "newDomElt", ")", "{", "var", "previousChild", "=", "newDomElt", ".", "lastChild", ";", "if", "(", "previousChild", ")", "{", "this", ".", "insertAdjacentElement", "(", "domElt", ",", "where", ",", "previousChild", ")", ";", "var", "curChild", "=", "newDomElt", ".", "lastChild", ";", "while", "(", "curChild", ")", "{", "containerElt", ".", "insertBefore", "(", "curChild", ",", "previousChild", ")", ";", "previousChild", "=", "curChild", ";", "curChild", "=", "newDomElt", ".", "lastChild", ";", "}", "}", "}", "else", "{", "throw", "ex", ";", "}", "}", "}", ";", "}", "else", "{", "this", ".", "insertAdjacentHTML", "=", "function", "(", "domElt", ",", "where", ",", "html", ")", "{", "var", "document", "=", "domElt", ".", "ownerDocument", ";", "var", "range", "=", "document", ".", "createRange", "(", ")", ";", "if", "(", "where", "==", "\"beforeBegin\"", "||", "where", "==", "\"afterEnd\"", ")", "{", "range", ".", "selectNode", "(", "domElt", ")", ";", "}", "else", "{", "range", ".", "selectNodeContents", "(", "domElt", ")", ";", "}", "var", "fragment", "=", "range", ".", "createContextualFragment", "(", "html", ")", ";", "this", ".", "insertAdjacentElement", "(", "domElt", ",", "where", ",", "fragment", ")", ";", "range", ".", "detach", "(", ")", ";", "}", ";", "}", "this", ".", "insertAdjacentHTML", "(", "domElt", ",", "where", ",", "html", ")", ";", "}" ]
Insert the given HTML markup into the document at the specified location. This method is cross-browser compatbile. When possible, it relies on the insertAdjacentHTML method, otherwise, it relies on ranges. @param {HTMLElement} domElt Reference DOM element @param {String} where maybe beforeBegin, afterBegin, beforeEnd or afterEnd @param {String} html HTML markup to insert at that place
[ "Insert", "the", "given", "HTML", "markup", "into", "the", "document", "at", "the", "specified", "location", ".", "This", "method", "is", "cross", "-", "browser", "compatbile", ".", "When", "possible", "it", "relies", "on", "the", "insertAdjacentHTML", "method", "otherwise", "it", "relies", "on", "ranges", "." ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Dom.js#L324-L387
train
ariatemplates/ariatemplates
src/aria/utils/Dom.js
function (domElt, where, newElement) { if (Aria.$window.document.body.insertAdjacentElement) { this.insertAdjacentElement = function (domElt, where, newElement) { domElt.insertAdjacentElement(where, newElement); }; } else { // Firefox :'( this.insertAdjacentElement = function (domElt, where, newElement) { if (where == "beforeBegin") { domElt.parentNode.insertBefore(newElement, domElt); } else if (where == "afterBegin") { domElt.insertBefore(newElement, domElt.firstChild); } else if (where == "beforeEnd") { domElt.appendChild(newElement); } else if (where == "afterEnd") { domElt.parentNode.insertBefore(newElement, domElt.nextSibling); } else { this.$logError(this.INSERT_ADJACENT_INVALID_POSITION, [where]); } }; } this.insertAdjacentElement(domElt, where, newElement); }
javascript
function (domElt, where, newElement) { if (Aria.$window.document.body.insertAdjacentElement) { this.insertAdjacentElement = function (domElt, where, newElement) { domElt.insertAdjacentElement(where, newElement); }; } else { // Firefox :'( this.insertAdjacentElement = function (domElt, where, newElement) { if (where == "beforeBegin") { domElt.parentNode.insertBefore(newElement, domElt); } else if (where == "afterBegin") { domElt.insertBefore(newElement, domElt.firstChild); } else if (where == "beforeEnd") { domElt.appendChild(newElement); } else if (where == "afterEnd") { domElt.parentNode.insertBefore(newElement, domElt.nextSibling); } else { this.$logError(this.INSERT_ADJACENT_INVALID_POSITION, [where]); } }; } this.insertAdjacentElement(domElt, where, newElement); }
[ "function", "(", "domElt", ",", "where", ",", "newElement", ")", "{", "if", "(", "Aria", ".", "$window", ".", "document", ".", "body", ".", "insertAdjacentElement", ")", "{", "this", ".", "insertAdjacentElement", "=", "function", "(", "domElt", ",", "where", ",", "newElement", ")", "{", "domElt", ".", "insertAdjacentElement", "(", "where", ",", "newElement", ")", ";", "}", ";", "}", "else", "{", "this", ".", "insertAdjacentElement", "=", "function", "(", "domElt", ",", "where", ",", "newElement", ")", "{", "if", "(", "where", "==", "\"beforeBegin\"", ")", "{", "domElt", ".", "parentNode", ".", "insertBefore", "(", "newElement", ",", "domElt", ")", ";", "}", "else", "if", "(", "where", "==", "\"afterBegin\"", ")", "{", "domElt", ".", "insertBefore", "(", "newElement", ",", "domElt", ".", "firstChild", ")", ";", "}", "else", "if", "(", "where", "==", "\"beforeEnd\"", ")", "{", "domElt", ".", "appendChild", "(", "newElement", ")", ";", "}", "else", "if", "(", "where", "==", "\"afterEnd\"", ")", "{", "domElt", ".", "parentNode", ".", "insertBefore", "(", "newElement", ",", "domElt", ".", "nextSibling", ")", ";", "}", "else", "{", "this", ".", "$logError", "(", "this", ".", "INSERT_ADJACENT_INVALID_POSITION", ",", "[", "where", "]", ")", ";", "}", "}", ";", "}", "this", ".", "insertAdjacentElement", "(", "domElt", ",", "where", ",", "newElement", ")", ";", "}" ]
Insert the given HTML element into the document at the specified location. This method is cross-browser compatbile. When possible, it relies on the insertAdjacentElement method, otherwise, it relies on insertBefore and appendChild. @param {HTMLElement} domElt Reference DOM element @param {String} where maybe beforeBegin, afterBegin, beforeEnd or afterEnd @param {String} html HTML markup to insert at that place
[ "Insert", "the", "given", "HTML", "element", "into", "the", "document", "at", "the", "specified", "location", ".", "This", "method", "is", "cross", "-", "browser", "compatbile", ".", "When", "possible", "it", "relies", "on", "the", "insertAdjacentElement", "method", "otherwise", "it", "relies", "on", "insertBefore", "and", "appendChild", "." ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Dom.js#L397-L420
train
ariatemplates/ariatemplates
src/aria/utils/Dom.js
function (src, dest) { // IE has a mergeAttributes method which does exactly that. Let's use it directly. // Note that copying attributes with a loop on attributes and setAttributes has strange results on IE7 (for // example, a TR can appear as disabled) if (Aria.$window.document.body.mergeAttributes) { this.copyAttributes = function (src, dest) { dest.mergeAttributes(src, false); }; } else { this.copyAttributes = function (src, dest) { // on other browsers, let's copy the attributes manually: var srcAttr = src.attributes; for (var i = 0, l = srcAttr.length; i < l; i++) { var attr = srcAttr[i]; dest.setAttribute(attr.name, attr.value); } }; } this.copyAttributes(src, dest); }
javascript
function (src, dest) { // IE has a mergeAttributes method which does exactly that. Let's use it directly. // Note that copying attributes with a loop on attributes and setAttributes has strange results on IE7 (for // example, a TR can appear as disabled) if (Aria.$window.document.body.mergeAttributes) { this.copyAttributes = function (src, dest) { dest.mergeAttributes(src, false); }; } else { this.copyAttributes = function (src, dest) { // on other browsers, let's copy the attributes manually: var srcAttr = src.attributes; for (var i = 0, l = srcAttr.length; i < l; i++) { var attr = srcAttr[i]; dest.setAttribute(attr.name, attr.value); } }; } this.copyAttributes(src, dest); }
[ "function", "(", "src", ",", "dest", ")", "{", "if", "(", "Aria", ".", "$window", ".", "document", ".", "body", ".", "mergeAttributes", ")", "{", "this", ".", "copyAttributes", "=", "function", "(", "src", ",", "dest", ")", "{", "dest", ".", "mergeAttributes", "(", "src", ",", "false", ")", ";", "}", ";", "}", "else", "{", "this", ".", "copyAttributes", "=", "function", "(", "src", ",", "dest", ")", "{", "var", "srcAttr", "=", "src", ".", "attributes", ";", "for", "(", "var", "i", "=", "0", ",", "l", "=", "srcAttr", ".", "length", ";", "i", "<", "l", ";", "i", "++", ")", "{", "var", "attr", "=", "srcAttr", "[", "i", "]", ";", "dest", ".", "setAttribute", "(", "attr", ".", "name", ",", "attr", ".", "value", ")", ";", "}", "}", ";", "}", "this", ".", "copyAttributes", "(", "src", ",", "dest", ")", ";", "}" ]
Copy attributes from one dom element to another. @param {HTMLElement} src Source element @param {HTMLElement} dest Destination element
[ "Copy", "attributes", "from", "one", "dom", "element", "to", "another", "." ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Dom.js#L427-L447
train
ariatemplates/ariatemplates
src/aria/utils/Dom.js
function () { if (ariaCoreBrowser.isIOS || ariaCoreBrowser.isAndroid) { // Initially (without user-initiated zoom) window's dimensions are the same or nearly the same as // documentElement's. // Note however that documentElement's clientWidth/Height is unaffected by user zoom while window's // innerWidth/Height change on zoom. // Also, in Safari on ipad, the viewport resizes when scrolling the page (the address bar is shrinked // gradually) and documentElement's size is unaffected, while window's size changes (but in Chrome on // mobile, both change). // See also http://jakub-g.github.io/quirksmode/widthtest.html return { 'width' : Aria.$window.innerWidth, 'height' : Aria.$window.innerHeight }; } else { var docEl = Aria.$window.document.documentElement; return { 'width' : docEl.clientWidth, 'height' : docEl.clientHeight }; } }
javascript
function () { if (ariaCoreBrowser.isIOS || ariaCoreBrowser.isAndroid) { // Initially (without user-initiated zoom) window's dimensions are the same or nearly the same as // documentElement's. // Note however that documentElement's clientWidth/Height is unaffected by user zoom while window's // innerWidth/Height change on zoom. // Also, in Safari on ipad, the viewport resizes when scrolling the page (the address bar is shrinked // gradually) and documentElement's size is unaffected, while window's size changes (but in Chrome on // mobile, both change). // See also http://jakub-g.github.io/quirksmode/widthtest.html return { 'width' : Aria.$window.innerWidth, 'height' : Aria.$window.innerHeight }; } else { var docEl = Aria.$window.document.documentElement; return { 'width' : docEl.clientWidth, 'height' : docEl.clientHeight }; } }
[ "function", "(", ")", "{", "if", "(", "ariaCoreBrowser", ".", "isIOS", "||", "ariaCoreBrowser", ".", "isAndroid", ")", "{", "return", "{", "'width'", ":", "Aria", ".", "$window", ".", "innerWidth", ",", "'height'", ":", "Aria", ".", "$window", ".", "innerHeight", "}", ";", "}", "else", "{", "var", "docEl", "=", "Aria", ".", "$window", ".", "document", ".", "documentElement", ";", "return", "{", "'width'", ":", "docEl", ".", "clientWidth", ",", "'height'", ":", "docEl", ".", "clientHeight", "}", ";", "}", "}" ]
Gets the dimensions of the viewport. Extracted from Closure's documentation. <pre> * Gecko standards mode: docEl.clientWidth Width of viewport excluding scrollbar. win.innerWidth Width of viewport including scrollbar. body.clientWidth Width of body element. docEl.clientHeight Height of viewport excluding scrollbar. win.innerHeight Height of viewport including scrollbar. body.clientHeight Height of document. Gecko Backwards compatible mode: docEl.clientWidth Width of viewport excluding scrollbar. win.innerWidth Width of viewport including scrollbar. body.clientWidth Width of viewport excluding scrollbar. docEl.clientHeight Height of document. win.innerHeight Height of viewport including scrollbar. body.clientHeight Height of viewport excluding scrollbar. IE6/7 Standards mode: docEl.clientWidth Width of viewport excluding scrollbar. win.innerWidth Undefined. body.clientWidth Width of body element. docEl.clientHeight Height of viewport excluding scrollbar. win.innerHeight Undefined. body.clientHeight Height of document element. IE5 + IE6/7 Backwards compatible mode: docEl.clientWidth 0. win.innerWidth Undefined. body.clientWidth Width of viewport excluding scrollbar. docEl.clientHeight 0. win.innerHeight Undefined. body.clientHeight Height of viewport excluding scrollbar. Opera 9 Standards and backwards compatible mode: docEl.clientWidth Width of viewport excluding scrollbar. win.innerWidth Width of viewport including scrollbar. body.clientWidth Width of viewport excluding scrollbar. docEl.clientHeight Height of document. win.innerHeight Height of viewport including scrollbar. body.clientHeight Height of viewport excluding scrollbar. WebKit: Safari 2 docEl.clientHeight Same as scrollHeight. docEl.clientWidth Same as innerWidth. win.innerWidth Width of viewport excluding scrollbar. win.innerHeight Height of the viewport including scrollbar. frame.innerHeight Height of the viewport exluding scrollbar. Safari 3 (tested in 522) docEl.clientWidth Width of viewport excluding scrollbar. docEl.clientHeight Height of viewport excluding scrollbar in strict mode. body.clientHeight Height of viewport excluding scrollbar in quirks mode. </pre> @return {aria.utils.DomBeans:Size} Size object width 'width' and 'height' properties @private
[ "Gets", "the", "dimensions", "of", "the", "viewport", ".", "Extracted", "from", "Closure", "s", "documentation", "." ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Dom.js#L517-L539
train
ariatemplates/ariatemplates
src/aria/utils/Dom.js
function (base) { var document = base && base.ownerDocument ? base.ownerDocument : Aria.$window.document; var scrollLeft = 0; var scrollTop = 0; var documentScroll = this.getDocumentScrollElement(document); if (base != null) { var next = base; while (next != null) { if (next.scrollLeft) { scrollLeft += next.scrollLeft; } if (next.scrollTop) { scrollTop += next.scrollTop; } next = next.parentNode; } // now subtract scroll offset of the document scrollLeft -= documentScroll.scrollLeft; scrollTop -= documentScroll.scrollTop; } else { scrollLeft = documentScroll.scrollLeft; scrollTop = documentScroll.scrollTop; } // this will be used to insert elements in the body, so body scrolls needs to be taken in consideration also if (documentScroll != document.body) { scrollLeft += document.body.scrollLeft; scrollTop += document.body.scrollTop; } var scroll = { 'scrollLeft' : scrollLeft, 'scrollTop' : scrollTop }; return scroll; }
javascript
function (base) { var document = base && base.ownerDocument ? base.ownerDocument : Aria.$window.document; var scrollLeft = 0; var scrollTop = 0; var documentScroll = this.getDocumentScrollElement(document); if (base != null) { var next = base; while (next != null) { if (next.scrollLeft) { scrollLeft += next.scrollLeft; } if (next.scrollTop) { scrollTop += next.scrollTop; } next = next.parentNode; } // now subtract scroll offset of the document scrollLeft -= documentScroll.scrollLeft; scrollTop -= documentScroll.scrollTop; } else { scrollLeft = documentScroll.scrollLeft; scrollTop = documentScroll.scrollTop; } // this will be used to insert elements in the body, so body scrolls needs to be taken in consideration also if (documentScroll != document.body) { scrollLeft += document.body.scrollLeft; scrollTop += document.body.scrollTop; } var scroll = { 'scrollLeft' : scrollLeft, 'scrollTop' : scrollTop }; return scroll; }
[ "function", "(", "base", ")", "{", "var", "document", "=", "base", "&&", "base", ".", "ownerDocument", "?", "base", ".", "ownerDocument", ":", "Aria", ".", "$window", ".", "document", ";", "var", "scrollLeft", "=", "0", ";", "var", "scrollTop", "=", "0", ";", "var", "documentScroll", "=", "this", ".", "getDocumentScrollElement", "(", "document", ")", ";", "if", "(", "base", "!=", "null", ")", "{", "var", "next", "=", "base", ";", "while", "(", "next", "!=", "null", ")", "{", "if", "(", "next", ".", "scrollLeft", ")", "{", "scrollLeft", "+=", "next", ".", "scrollLeft", ";", "}", "if", "(", "next", ".", "scrollTop", ")", "{", "scrollTop", "+=", "next", ".", "scrollTop", ";", "}", "next", "=", "next", ".", "parentNode", ";", "}", "scrollLeft", "-=", "documentScroll", ".", "scrollLeft", ";", "scrollTop", "-=", "documentScroll", ".", "scrollTop", ";", "}", "else", "{", "scrollLeft", "=", "documentScroll", ".", "scrollLeft", ";", "scrollTop", "=", "documentScroll", ".", "scrollTop", ";", "}", "if", "(", "documentScroll", "!=", "document", ".", "body", ")", "{", "scrollLeft", "+=", "document", ".", "body", ".", "scrollLeft", ";", "scrollTop", "+=", "document", ".", "body", ".", "scrollTop", ";", "}", "var", "scroll", "=", "{", "'scrollLeft'", ":", "scrollLeft", ",", "'scrollTop'", ":", "scrollTop", "}", ";", "return", "scroll", ";", "}" ]
Gets the document scroll distance as a coordinate object. @parameter {Object} base If provided, the total scrolling offset of the base element is calculated, minus the scrolling offset of the document element @return {Object} Object with values 'scrollLeft' and 'scrollTop'. @protected
[ "Gets", "the", "document", "scroll", "distance", "as", "a", "coordinate", "object", "." ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Dom.js#L569-L606
train
ariatemplates/ariatemplates
src/aria/utils/Dom.js
function () { // https://developer.mozilla.org/en/DOM/window.scrollMaxY suggests not to use scrollMaxY // Take the maximum between the document and the viewport srollWidth/Height // PTR 04677501 AT-Release1.0-36 release bug fixing: Safari has the correct scrollWidth and scrollHeight in // document.body var doc = this.getDocumentScrollElement(); var docSize = { width : doc.scrollWidth, height : doc.scrollHeight }; var vieportSize = this._getViewportSize(); return { width : Math.max(docSize.width, vieportSize.width), height : Math.max(docSize.height, vieportSize.height) }; }
javascript
function () { // https://developer.mozilla.org/en/DOM/window.scrollMaxY suggests not to use scrollMaxY // Take the maximum between the document and the viewport srollWidth/Height // PTR 04677501 AT-Release1.0-36 release bug fixing: Safari has the correct scrollWidth and scrollHeight in // document.body var doc = this.getDocumentScrollElement(); var docSize = { width : doc.scrollWidth, height : doc.scrollHeight }; var vieportSize = this._getViewportSize(); return { width : Math.max(docSize.width, vieportSize.width), height : Math.max(docSize.height, vieportSize.height) }; }
[ "function", "(", ")", "{", "var", "doc", "=", "this", ".", "getDocumentScrollElement", "(", ")", ";", "var", "docSize", "=", "{", "width", ":", "doc", ".", "scrollWidth", ",", "height", ":", "doc", ".", "scrollHeight", "}", ";", "var", "vieportSize", "=", "this", ".", "_getViewportSize", "(", ")", ";", "return", "{", "width", ":", "Math", ".", "max", "(", "docSize", ".", "width", ",", "vieportSize", ".", "width", ")", ",", "height", ":", "Math", ".", "max", "(", "docSize", ".", "height", ",", "vieportSize", ".", "height", ")", "}", ";", "}" ]
Get the full size of the page. It is bigger than the viewport size if there are scrollbars, otherwise it's the viewport size @return {aria.utils.DomBeans:Size} Size object
[ "Get", "the", "full", "size", "of", "the", "page", ".", "It", "is", "bigger", "than", "the", "viewport", "size", "if", "there", "are", "scrollbars", "otherwise", "it", "s", "the", "viewport", "size" ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Dom.js#L613-L631
train
ariatemplates/ariatemplates
src/aria/utils/Dom.js
function (element, property) { var browser = ariaCoreBrowser; var isIE8orLess = browser.isIE8 || browser.isIE7; if (isIE8orLess) { this.getStyle = function (element, property) { if (property == 'opacity') {// IE<=8 opacity uses filter var val = 100; try { // will error if no DXImageTransform val = element.filters['DXImageTransform.Microsoft.Alpha'].opacity; } catch (e) { try { // make sure its in the document val = element.filters('alpha').opacity; } catch (er) {} } return (val / 100).toString(10); // to be consistent with getComputedStyle } else if (property == 'width' || property == 'height') { return ariaUtilsCssUnits.getDomWidthOrHeightForOldIE(element, property); } else if (property == 'float') { // fix reserved word property = 'styleFloat'; // fall through } var value; // test currentStyle before touching if (element.currentStyle) { value = element.currentStyle[property]; if (!value) { // Try the camel case var camel = ariaUtilsString.dashedToCamel(property); value = element.currentStyle[camel]; } } return (value || element.style[property]); }; } else { this.getStyle = function (element, property) { var window = Aria.$window; var value = null; if (property == "float") { property = "cssFloat"; } else if (property == "backgroundPositionX" || property == "backgroundPositionY") { // backgroundPositionX and backgroundPositionY are not standard var backgroundPosition = this.getStyle(element, "backgroundPosition"); if (backgroundPosition) { var match = /^([-.0-9a-z%]+)\s([-.0-9a-z%]+)($|,)/.exec(backgroundPosition); if (match) { value = ((property == "backgroundPositionX") ? match[1] : match[2]); } } return value; } var computed = window.getComputedStyle(element, ""); if (computed) { value = computed[property]; } return (value || element.style[property]); }; } return this.getStyle(element, property); }
javascript
function (element, property) { var browser = ariaCoreBrowser; var isIE8orLess = browser.isIE8 || browser.isIE7; if (isIE8orLess) { this.getStyle = function (element, property) { if (property == 'opacity') {// IE<=8 opacity uses filter var val = 100; try { // will error if no DXImageTransform val = element.filters['DXImageTransform.Microsoft.Alpha'].opacity; } catch (e) { try { // make sure its in the document val = element.filters('alpha').opacity; } catch (er) {} } return (val / 100).toString(10); // to be consistent with getComputedStyle } else if (property == 'width' || property == 'height') { return ariaUtilsCssUnits.getDomWidthOrHeightForOldIE(element, property); } else if (property == 'float') { // fix reserved word property = 'styleFloat'; // fall through } var value; // test currentStyle before touching if (element.currentStyle) { value = element.currentStyle[property]; if (!value) { // Try the camel case var camel = ariaUtilsString.dashedToCamel(property); value = element.currentStyle[camel]; } } return (value || element.style[property]); }; } else { this.getStyle = function (element, property) { var window = Aria.$window; var value = null; if (property == "float") { property = "cssFloat"; } else if (property == "backgroundPositionX" || property == "backgroundPositionY") { // backgroundPositionX and backgroundPositionY are not standard var backgroundPosition = this.getStyle(element, "backgroundPosition"); if (backgroundPosition) { var match = /^([-.0-9a-z%]+)\s([-.0-9a-z%]+)($|,)/.exec(backgroundPosition); if (match) { value = ((property == "backgroundPositionX") ? match[1] : match[2]); } } return value; } var computed = window.getComputedStyle(element, ""); if (computed) { value = computed[property]; } return (value || element.style[property]); }; } return this.getStyle(element, property); }
[ "function", "(", "element", ",", "property", ")", "{", "var", "browser", "=", "ariaCoreBrowser", ";", "var", "isIE8orLess", "=", "browser", ".", "isIE8", "||", "browser", ".", "isIE7", ";", "if", "(", "isIE8orLess", ")", "{", "this", ".", "getStyle", "=", "function", "(", "element", ",", "property", ")", "{", "if", "(", "property", "==", "'opacity'", ")", "{", "var", "val", "=", "100", ";", "try", "{", "val", "=", "element", ".", "filters", "[", "'DXImageTransform.Microsoft.Alpha'", "]", ".", "opacity", ";", "}", "catch", "(", "e", ")", "{", "try", "{", "val", "=", "element", ".", "filters", "(", "'alpha'", ")", ".", "opacity", ";", "}", "catch", "(", "er", ")", "{", "}", "}", "return", "(", "val", "/", "100", ")", ".", "toString", "(", "10", ")", ";", "}", "else", "if", "(", "property", "==", "'width'", "||", "property", "==", "'height'", ")", "{", "return", "ariaUtilsCssUnits", ".", "getDomWidthOrHeightForOldIE", "(", "element", ",", "property", ")", ";", "}", "else", "if", "(", "property", "==", "'float'", ")", "{", "property", "=", "'styleFloat'", ";", "}", "var", "value", ";", "if", "(", "element", ".", "currentStyle", ")", "{", "value", "=", "element", ".", "currentStyle", "[", "property", "]", ";", "if", "(", "!", "value", ")", "{", "var", "camel", "=", "ariaUtilsString", ".", "dashedToCamel", "(", "property", ")", ";", "value", "=", "element", ".", "currentStyle", "[", "camel", "]", ";", "}", "}", "return", "(", "value", "||", "element", ".", "style", "[", "property", "]", ")", ";", "}", ";", "}", "else", "{", "this", ".", "getStyle", "=", "function", "(", "element", ",", "property", ")", "{", "var", "window", "=", "Aria", ".", "$window", ";", "var", "value", "=", "null", ";", "if", "(", "property", "==", "\"float\"", ")", "{", "property", "=", "\"cssFloat\"", ";", "}", "else", "if", "(", "property", "==", "\"backgroundPositionX\"", "||", "property", "==", "\"backgroundPositionY\"", ")", "{", "var", "backgroundPosition", "=", "this", ".", "getStyle", "(", "element", ",", "\"backgroundPosition\"", ")", ";", "if", "(", "backgroundPosition", ")", "{", "var", "match", "=", "/", "^([-.0-9a-z%]+)\\s([-.0-9a-z%]+)($|,)", "/", ".", "exec", "(", "backgroundPosition", ")", ";", "if", "(", "match", ")", "{", "value", "=", "(", "(", "property", "==", "\"backgroundPositionX\"", ")", "?", "match", "[", "1", "]", ":", "match", "[", "2", "]", ")", ";", "}", "}", "return", "value", ";", "}", "var", "computed", "=", "window", ".", "getComputedStyle", "(", "element", ",", "\"\"", ")", ";", "if", "(", "computed", ")", "{", "value", "=", "computed", "[", "property", "]", ";", "}", "return", "(", "value", "||", "element", ".", "style", "[", "property", "]", ")", ";", "}", ";", "}", "return", "this", ".", "getStyle", "(", "element", ",", "property", ")", ";", "}" ]
Retrieve the computed style for a given CSS property on a given DOM element. @param {HTMLElement} element The DOM element on which to retrieve a CSS property @param {String} property The CSS property to retrieve. For maximum portability, it should be in camel case (for instance <code>backgroundImage</code>)
[ "Retrieve", "the", "computed", "style", "for", "a", "given", "CSS", "property", "on", "a", "given", "DOM", "element", "." ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Dom.js#L908-L966
train
ariatemplates/ariatemplates
src/aria/utils/Dom.js
function (size, base) { var viewportSize = this._getViewportSize(); var documentScroll = this._getDocumentScroll(base); return { left : parseInt(documentScroll.scrollLeft + (viewportSize.width - size.width) / 2, 10), top : parseInt(documentScroll.scrollTop + (viewportSize.height - size.height) / 2, 10) }; }
javascript
function (size, base) { var viewportSize = this._getViewportSize(); var documentScroll = this._getDocumentScroll(base); return { left : parseInt(documentScroll.scrollLeft + (viewportSize.width - size.width) / 2, 10), top : parseInt(documentScroll.scrollTop + (viewportSize.height - size.height) / 2, 10) }; }
[ "function", "(", "size", ",", "base", ")", "{", "var", "viewportSize", "=", "this", ".", "_getViewportSize", "(", ")", ";", "var", "documentScroll", "=", "this", ".", "_getDocumentScroll", "(", "base", ")", ";", "return", "{", "left", ":", "parseInt", "(", "documentScroll", ".", "scrollLeft", "+", "(", "viewportSize", ".", "width", "-", "size", ".", "width", ")", "/", "2", ",", "10", ")", ",", "top", ":", "parseInt", "(", "documentScroll", ".", "scrollTop", "+", "(", "viewportSize", ".", "height", "-", "size", ".", "height", ")", "/", "2", ",", "10", ")", "}", ";", "}" ]
Center the given size in the viewport. @param {aria.utils.DomBeans:Size} size size of the element to center in the viewport @param {Object} base The base element used to account for scrolling offsets @return {aria.utils.DomBeans:Position} position of the element when centered in the viewport
[ "Center", "the", "given", "size", "in", "the", "viewport", "." ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Dom.js#L974-L981
train
ariatemplates/ariatemplates
src/aria/utils/Dom.js
function (position, size, base) { var viewportSize = this._getViewportSize(); var documentScroll = this._getDocumentScroll(base); if (position.top < documentScroll.scrollTop || position.left < documentScroll.scrollLeft || position.top + size.height > documentScroll.scrollTop + viewportSize.height || position.left + size.width > documentScroll.scrollLeft + viewportSize.width) { return false; } else { return true; } }
javascript
function (position, size, base) { var viewportSize = this._getViewportSize(); var documentScroll = this._getDocumentScroll(base); if (position.top < documentScroll.scrollTop || position.left < documentScroll.scrollLeft || position.top + size.height > documentScroll.scrollTop + viewportSize.height || position.left + size.width > documentScroll.scrollLeft + viewportSize.width) { return false; } else { return true; } }
[ "function", "(", "position", ",", "size", ",", "base", ")", "{", "var", "viewportSize", "=", "this", ".", "_getViewportSize", "(", ")", ";", "var", "documentScroll", "=", "this", ".", "_getDocumentScroll", "(", "base", ")", ";", "if", "(", "position", ".", "top", "<", "documentScroll", ".", "scrollTop", "||", "position", ".", "left", "<", "documentScroll", ".", "scrollLeft", "||", "position", ".", "top", "+", "size", ".", "height", ">", "documentScroll", ".", "scrollTop", "+", "viewportSize", ".", "height", "||", "position", ".", "left", "+", "size", ".", "width", ">", "documentScroll", ".", "scrollLeft", "+", "viewportSize", ".", "width", ")", "{", "return", "false", ";", "}", "else", "{", "return", "true", ";", "}", "}" ]
Check if a given position + size couple can fit in the current viewport @param {aria.utils.DomBeans:Position} position @param {aria.utils.DomBeans:Size} size @param {Object} base The base element used to account for scrolling offsets @return {Boolean} True if the given position+size couple can fit in the current viewport
[ "Check", "if", "a", "given", "position", "+", "size", "couple", "can", "fit", "in", "the", "current", "viewport" ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Dom.js#L990-L1001
train
ariatemplates/ariatemplates
src/aria/utils/Dom.js
function (needle, haystack) { needle.width = needle.width || 0; needle.height = needle.height || 0; if (haystack == this.VIEWPORT) { return this.isInViewport({ left : needle.x, top : needle.y }, { width : needle.width, height : needle.height }); } haystack.width = haystack.width || 0; haystack.height = haystack.height || 0; if (needle.x < haystack.x || needle.y < haystack.y || needle.x + needle.width > haystack.x + haystack.width || needle.y + needle.height > haystack.y + haystack.height) { return false; } return true; }
javascript
function (needle, haystack) { needle.width = needle.width || 0; needle.height = needle.height || 0; if (haystack == this.VIEWPORT) { return this.isInViewport({ left : needle.x, top : needle.y }, { width : needle.width, height : needle.height }); } haystack.width = haystack.width || 0; haystack.height = haystack.height || 0; if (needle.x < haystack.x || needle.y < haystack.y || needle.x + needle.width > haystack.x + haystack.width || needle.y + needle.height > haystack.y + haystack.height) { return false; } return true; }
[ "function", "(", "needle", ",", "haystack", ")", "{", "needle", ".", "width", "=", "needle", ".", "width", "||", "0", ";", "needle", ".", "height", "=", "needle", ".", "height", "||", "0", ";", "if", "(", "haystack", "==", "this", ".", "VIEWPORT", ")", "{", "return", "this", ".", "isInViewport", "(", "{", "left", ":", "needle", ".", "x", ",", "top", ":", "needle", ".", "y", "}", ",", "{", "width", ":", "needle", ".", "width", ",", "height", ":", "needle", ".", "height", "}", ")", ";", "}", "haystack", ".", "width", "=", "haystack", ".", "width", "||", "0", ";", "haystack", ".", "height", "=", "haystack", ".", "height", "||", "0", ";", "if", "(", "needle", ".", "x", "<", "haystack", ".", "x", "||", "needle", ".", "y", "<", "haystack", ".", "y", "||", "needle", ".", "x", "+", "needle", ".", "width", ">", "haystack", ".", "x", "+", "haystack", ".", "width", "||", "needle", ".", "y", "+", "needle", ".", "height", ">", "haystack", ".", "y", "+", "haystack", ".", "height", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Compares two geometries to ascertain whether an element is inside another one @param {aria.utils.DomBeans:Geometry} needle @param {aria.utils.DomBeans:Geometry|aria.utils.Dom:VIEWPORT:property} haystack @return {Boolean}
[ "Compares", "two", "geometries", "to", "ascertain", "whether", "an", "element", "is", "inside", "another", "one" ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Dom.js#L1009-L1028
train
ariatemplates/ariatemplates
src/aria/utils/Dom.js
function (position, size, base) { var viewportSize = this._getViewportSize(); var documentScroll = this._getDocumentScroll(base); var minTopValue = documentScroll.scrollTop; var maxTopValue = Math.max(0, documentScroll.scrollTop + viewportSize.height - size.height); var top = aria.utils.Math.normalize(position.top, minTopValue, maxTopValue); var minLeftValue = documentScroll.scrollLeft; var maxLeftValue = Math.max(0, documentScroll.scrollLeft + viewportSize.width - size.width); var left = aria.utils.Math.normalize(position.left, minLeftValue, maxLeftValue); return { 'top' : top, 'left' : left }; }
javascript
function (position, size, base) { var viewportSize = this._getViewportSize(); var documentScroll = this._getDocumentScroll(base); var minTopValue = documentScroll.scrollTop; var maxTopValue = Math.max(0, documentScroll.scrollTop + viewportSize.height - size.height); var top = aria.utils.Math.normalize(position.top, minTopValue, maxTopValue); var minLeftValue = documentScroll.scrollLeft; var maxLeftValue = Math.max(0, documentScroll.scrollLeft + viewportSize.width - size.width); var left = aria.utils.Math.normalize(position.left, minLeftValue, maxLeftValue); return { 'top' : top, 'left' : left }; }
[ "function", "(", "position", ",", "size", ",", "base", ")", "{", "var", "viewportSize", "=", "this", ".", "_getViewportSize", "(", ")", ";", "var", "documentScroll", "=", "this", ".", "_getDocumentScroll", "(", "base", ")", ";", "var", "minTopValue", "=", "documentScroll", ".", "scrollTop", ";", "var", "maxTopValue", "=", "Math", ".", "max", "(", "0", ",", "documentScroll", ".", "scrollTop", "+", "viewportSize", ".", "height", "-", "size", ".", "height", ")", ";", "var", "top", "=", "aria", ".", "utils", ".", "Math", ".", "normalize", "(", "position", ".", "top", ",", "minTopValue", ",", "maxTopValue", ")", ";", "var", "minLeftValue", "=", "documentScroll", ".", "scrollLeft", ";", "var", "maxLeftValue", "=", "Math", ".", "max", "(", "0", ",", "documentScroll", ".", "scrollLeft", "+", "viewportSize", ".", "width", "-", "size", ".", "width", ")", ";", "var", "left", "=", "aria", ".", "utils", ".", "Math", ".", "normalize", "(", "position", ".", "left", ",", "minLeftValue", ",", "maxLeftValue", ")", ";", "return", "{", "'top'", ":", "top", ",", "'left'", ":", "left", "}", ";", "}" ]
Given a position + size couple, return a corrected position that should fit in the viewport. If the size is bigger than the vieport it returns a position such that the top left corner of the element to be fit is in the viewport. @param {aria.utils.DomBeans:Position} position @param {aria.utils.DomBeans:Size} size @param {Object} base The base element used to account for scrolling offsets @return {aria.utils.DomBeans:Position}
[ "Given", "a", "position", "+", "size", "couple", "return", "a", "corrected", "position", "that", "should", "fit", "in", "the", "viewport", ".", "If", "the", "size", "is", "bigger", "than", "the", "vieport", "it", "returns", "a", "position", "such", "that", "the", "top", "left", "corner", "of", "the", "element", "to", "be", "fit", "is", "in", "the", "viewport", "." ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Dom.js#L1039-L1055
train
ariatemplates/ariatemplates
src/aria/utils/Dom.js
function (geometry, container) { geometry.width = geometry.width || 0; geometry.height = geometry.height || 0; if (container == this.VIEWPORT) { container = this.getViewportSize(); container.x = container.y = 0; } container.width = container.width || 0; container.height = container.height || 0; var left = (geometry.x < container.x) ? container.x : geometry.x; var top = (geometry.y < container.y) ? container.y : geometry.y; if (geometry.x + geometry.width > container.x + container.width) { left = container.x + container.width - geometry.width; } if (geometry.y + geometry.height > container.y + container.height) { top = container.y + container.height - geometry.height; } return { 'top' : top, 'left' : left }; }
javascript
function (geometry, container) { geometry.width = geometry.width || 0; geometry.height = geometry.height || 0; if (container == this.VIEWPORT) { container = this.getViewportSize(); container.x = container.y = 0; } container.width = container.width || 0; container.height = container.height || 0; var left = (geometry.x < container.x) ? container.x : geometry.x; var top = (geometry.y < container.y) ? container.y : geometry.y; if (geometry.x + geometry.width > container.x + container.width) { left = container.x + container.width - geometry.width; } if (geometry.y + geometry.height > container.y + container.height) { top = container.y + container.height - geometry.height; } return { 'top' : top, 'left' : left }; }
[ "function", "(", "geometry", ",", "container", ")", "{", "geometry", ".", "width", "=", "geometry", ".", "width", "||", "0", ";", "geometry", ".", "height", "=", "geometry", ".", "height", "||", "0", ";", "if", "(", "container", "==", "this", ".", "VIEWPORT", ")", "{", "container", "=", "this", ".", "getViewportSize", "(", ")", ";", "container", ".", "x", "=", "container", ".", "y", "=", "0", ";", "}", "container", ".", "width", "=", "container", ".", "width", "||", "0", ";", "container", ".", "height", "=", "container", ".", "height", "||", "0", ";", "var", "left", "=", "(", "geometry", ".", "x", "<", "container", ".", "x", ")", "?", "container", ".", "x", ":", "geometry", ".", "x", ";", "var", "top", "=", "(", "geometry", ".", "y", "<", "container", ".", "y", ")", "?", "container", ".", "y", ":", "geometry", ".", "y", ";", "if", "(", "geometry", ".", "x", "+", "geometry", ".", "width", ">", "container", ".", "x", "+", "container", ".", "width", ")", "{", "left", "=", "container", ".", "x", "+", "container", ".", "width", "-", "geometry", ".", "width", ";", "}", "if", "(", "geometry", ".", "y", "+", "geometry", ".", "height", ">", "container", ".", "y", "+", "container", ".", "height", ")", "{", "top", "=", "container", ".", "y", "+", "container", ".", "height", "-", "geometry", ".", "height", ";", "}", "return", "{", "'top'", ":", "top", ",", "'left'", ":", "left", "}", ";", "}" ]
Fits a geometry into another geometry @param {aria.utils.DomBeans:Geometry} geometry @param {aria.utils.DomBeans:Geometry|aria.utils.Dom:VIEWPORT:property} container @return {aria.utils.DomBeans:Position} top and left values of the fitted geometry
[ "Fits", "a", "geometry", "into", "another", "geometry" ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Dom.js#L1063-L1085
train
ariatemplates/ariatemplates
src/aria/utils/Dom.js
function (child, parent) { if (!(child && child.ownerDocument)) { return false; } var document = child.ownerDocument; var body = document.body; var element = child; while (element && element != body) { if (element == parent) { return true; } element = element.parentNode; } return (element == parent); // can be true if parent == body and element is present in DOM }
javascript
function (child, parent) { if (!(child && child.ownerDocument)) { return false; } var document = child.ownerDocument; var body = document.body; var element = child; while (element && element != body) { if (element == parent) { return true; } element = element.parentNode; } return (element == parent); // can be true if parent == body and element is present in DOM }
[ "function", "(", "child", ",", "parent", ")", "{", "if", "(", "!", "(", "child", "&&", "child", ".", "ownerDocument", ")", ")", "{", "return", "false", ";", "}", "var", "document", "=", "child", ".", "ownerDocument", ";", "var", "body", "=", "document", ".", "body", ";", "var", "element", "=", "child", ";", "while", "(", "element", "&&", "element", "!=", "body", ")", "{", "if", "(", "element", "==", "parent", ")", "{", "return", "true", ";", "}", "element", "=", "element", ".", "parentNode", ";", "}", "return", "(", "element", "==", "parent", ")", ";", "}" ]
Check whether a child element is a child element of a particular parentNode @param {HTMLElement} child The child DOM element to check @param {HTMLElement} parent The parent DOM element to check @return {Boolean} True if the given child is a child of the given parent
[ "Check", "whether", "a", "child", "element", "is", "a", "child", "element", "of", "a", "particular", "parentNode" ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Dom.js#L1093-L1107
train
ariatemplates/ariatemplates
src/aria/utils/Dom.js
function (element, alignTop) { var document = element.ownerDocument; var origin = element, originRect = origin.getBoundingClientRect(); var hasScroll = false; var documentScroll = this.getDocumentScrollElement(document); while (element) { if (element == document.body) { element = documentScroll; } else { element = element.parentNode; } if (element) { var hasScrollbar = (!element.clientHeight) ? false : element.scrollHeight > element.clientHeight; if (!hasScrollbar && element == documentScroll && documentScroll == document.body) { var docElement = document.documentElement; // On Chrome, documentScroll == document.body due to https://code.google.com/p/chromium/issues/detail?id=157855 // But if the body has no margin: document.body.scrollHeight == document.body.clientHeight // and hasScrollbar can be false even if there is a scrollbar. That's why the following line was added: hasScrollbar = (!docElement || !docElement.clientHeight) ? false : docElement.scrollHeight > docElement.clientHeight; } if (!hasScrollbar) { if (element == documentScroll) { element = null; } continue; } var rects; if (element == documentScroll) { rects = { left : 0, top : 0 }; } else { rects = element.getBoundingClientRect(); } // check that elementRect is in rects var deltaLeft = originRect.left - (rects.left + (parseInt(element.style.borderLeftWidth, 10) | 0)); var deltaRight = originRect.right - (rects.left + element.clientWidth + (parseInt(element.style.borderLeftWidth, 10) | 0)); var deltaTop = originRect.top - (rects.top + (parseInt(element.style.borderTopWidth, 10) | 0)); var deltaBottom = originRect.bottom - (rects.top + element.clientHeight + (parseInt(element.style.borderTopWidth, 10) | 0)); // adjust display depending on deltas if (deltaLeft < 0) { element.scrollLeft += deltaLeft; } else if (deltaRight > 0) { element.scrollLeft += deltaRight; } if (alignTop === true && !hasScroll) { element.scrollTop += deltaTop; } else if (alignTop === false && !hasScroll) { element.scrollTop += deltaBottom; } else { if (deltaTop < 0) { element.scrollTop += deltaTop; } else if (deltaBottom > 0) { element.scrollTop += deltaBottom; } } if (element == documentScroll) { element = null; } else { // readjust element position after scrolls, and check if vertical scroll has changed. // this is required to perform only one alignment var nextRect = origin.getBoundingClientRect(); if (nextRect.top != originRect.top) { hasScroll = true; } originRect = nextRect; } } } }
javascript
function (element, alignTop) { var document = element.ownerDocument; var origin = element, originRect = origin.getBoundingClientRect(); var hasScroll = false; var documentScroll = this.getDocumentScrollElement(document); while (element) { if (element == document.body) { element = documentScroll; } else { element = element.parentNode; } if (element) { var hasScrollbar = (!element.clientHeight) ? false : element.scrollHeight > element.clientHeight; if (!hasScrollbar && element == documentScroll && documentScroll == document.body) { var docElement = document.documentElement; // On Chrome, documentScroll == document.body due to https://code.google.com/p/chromium/issues/detail?id=157855 // But if the body has no margin: document.body.scrollHeight == document.body.clientHeight // and hasScrollbar can be false even if there is a scrollbar. That's why the following line was added: hasScrollbar = (!docElement || !docElement.clientHeight) ? false : docElement.scrollHeight > docElement.clientHeight; } if (!hasScrollbar) { if (element == documentScroll) { element = null; } continue; } var rects; if (element == documentScroll) { rects = { left : 0, top : 0 }; } else { rects = element.getBoundingClientRect(); } // check that elementRect is in rects var deltaLeft = originRect.left - (rects.left + (parseInt(element.style.borderLeftWidth, 10) | 0)); var deltaRight = originRect.right - (rects.left + element.clientWidth + (parseInt(element.style.borderLeftWidth, 10) | 0)); var deltaTop = originRect.top - (rects.top + (parseInt(element.style.borderTopWidth, 10) | 0)); var deltaBottom = originRect.bottom - (rects.top + element.clientHeight + (parseInt(element.style.borderTopWidth, 10) | 0)); // adjust display depending on deltas if (deltaLeft < 0) { element.scrollLeft += deltaLeft; } else if (deltaRight > 0) { element.scrollLeft += deltaRight; } if (alignTop === true && !hasScroll) { element.scrollTop += deltaTop; } else if (alignTop === false && !hasScroll) { element.scrollTop += deltaBottom; } else { if (deltaTop < 0) { element.scrollTop += deltaTop; } else if (deltaBottom > 0) { element.scrollTop += deltaBottom; } } if (element == documentScroll) { element = null; } else { // readjust element position after scrolls, and check if vertical scroll has changed. // this is required to perform only one alignment var nextRect = origin.getBoundingClientRect(); if (nextRect.top != originRect.top) { hasScroll = true; } originRect = nextRect; } } } }
[ "function", "(", "element", ",", "alignTop", ")", "{", "var", "document", "=", "element", ".", "ownerDocument", ";", "var", "origin", "=", "element", ",", "originRect", "=", "origin", ".", "getBoundingClientRect", "(", ")", ";", "var", "hasScroll", "=", "false", ";", "var", "documentScroll", "=", "this", ".", "getDocumentScrollElement", "(", "document", ")", ";", "while", "(", "element", ")", "{", "if", "(", "element", "==", "document", ".", "body", ")", "{", "element", "=", "documentScroll", ";", "}", "else", "{", "element", "=", "element", ".", "parentNode", ";", "}", "if", "(", "element", ")", "{", "var", "hasScrollbar", "=", "(", "!", "element", ".", "clientHeight", ")", "?", "false", ":", "element", ".", "scrollHeight", ">", "element", ".", "clientHeight", ";", "if", "(", "!", "hasScrollbar", "&&", "element", "==", "documentScroll", "&&", "documentScroll", "==", "document", ".", "body", ")", "{", "var", "docElement", "=", "document", ".", "documentElement", ";", "hasScrollbar", "=", "(", "!", "docElement", "||", "!", "docElement", ".", "clientHeight", ")", "?", "false", ":", "docElement", ".", "scrollHeight", ">", "docElement", ".", "clientHeight", ";", "}", "if", "(", "!", "hasScrollbar", ")", "{", "if", "(", "element", "==", "documentScroll", ")", "{", "element", "=", "null", ";", "}", "continue", ";", "}", "var", "rects", ";", "if", "(", "element", "==", "documentScroll", ")", "{", "rects", "=", "{", "left", ":", "0", ",", "top", ":", "0", "}", ";", "}", "else", "{", "rects", "=", "element", ".", "getBoundingClientRect", "(", ")", ";", "}", "var", "deltaLeft", "=", "originRect", ".", "left", "-", "(", "rects", ".", "left", "+", "(", "parseInt", "(", "element", ".", "style", ".", "borderLeftWidth", ",", "10", ")", "|", "0", ")", ")", ";", "var", "deltaRight", "=", "originRect", ".", "right", "-", "(", "rects", ".", "left", "+", "element", ".", "clientWidth", "+", "(", "parseInt", "(", "element", ".", "style", ".", "borderLeftWidth", ",", "10", ")", "|", "0", ")", ")", ";", "var", "deltaTop", "=", "originRect", ".", "top", "-", "(", "rects", ".", "top", "+", "(", "parseInt", "(", "element", ".", "style", ".", "borderTopWidth", ",", "10", ")", "|", "0", ")", ")", ";", "var", "deltaBottom", "=", "originRect", ".", "bottom", "-", "(", "rects", ".", "top", "+", "element", ".", "clientHeight", "+", "(", "parseInt", "(", "element", ".", "style", ".", "borderTopWidth", ",", "10", ")", "|", "0", ")", ")", ";", "if", "(", "deltaLeft", "<", "0", ")", "{", "element", ".", "scrollLeft", "+=", "deltaLeft", ";", "}", "else", "if", "(", "deltaRight", ">", "0", ")", "{", "element", ".", "scrollLeft", "+=", "deltaRight", ";", "}", "if", "(", "alignTop", "===", "true", "&&", "!", "hasScroll", ")", "{", "element", ".", "scrollTop", "+=", "deltaTop", ";", "}", "else", "if", "(", "alignTop", "===", "false", "&&", "!", "hasScroll", ")", "{", "element", ".", "scrollTop", "+=", "deltaBottom", ";", "}", "else", "{", "if", "(", "deltaTop", "<", "0", ")", "{", "element", ".", "scrollTop", "+=", "deltaTop", ";", "}", "else", "if", "(", "deltaBottom", ">", "0", ")", "{", "element", ".", "scrollTop", "+=", "deltaBottom", ";", "}", "}", "if", "(", "element", "==", "documentScroll", ")", "{", "element", "=", "null", ";", "}", "else", "{", "var", "nextRect", "=", "origin", ".", "getBoundingClientRect", "(", ")", ";", "if", "(", "nextRect", ".", "top", "!=", "originRect", ".", "top", ")", "{", "hasScroll", "=", "true", ";", "}", "originRect", "=", "nextRect", ";", "}", "}", "}", "}" ]
Change scrollbar positions to ensure that an item is visible. @param {HTMLElement} element element which is to be made visible @param {Boolean} alignTop if true align top of the element with top of container. if false, align bottom. If not specified, does "minimal job".
[ "Change", "scrollbar", "positions", "to", "ensure", "that", "an", "item", "is", "visible", "." ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Dom.js#L1135-L1217
train
ariatemplates/ariatemplates
src/aria/utils/Dom.js
function (element, opacity) { var browser = ariaCoreBrowser; var isIE8OrLess = (browser.isIE8 || browser.isIE7); this.setOpacity = isIE8OrLess ? this._setOpacityLegacyIE : this._setOpacityW3C; this.setOpacity(element, opacity); }
javascript
function (element, opacity) { var browser = ariaCoreBrowser; var isIE8OrLess = (browser.isIE8 || browser.isIE7); this.setOpacity = isIE8OrLess ? this._setOpacityLegacyIE : this._setOpacityW3C; this.setOpacity(element, opacity); }
[ "function", "(", "element", ",", "opacity", ")", "{", "var", "browser", "=", "ariaCoreBrowser", ";", "var", "isIE8OrLess", "=", "(", "browser", ".", "isIE8", "||", "browser", ".", "isIE7", ")", ";", "this", ".", "setOpacity", "=", "isIE8OrLess", "?", "this", ".", "_setOpacityLegacyIE", ":", "this", ".", "_setOpacityW3C", ";", "this", ".", "setOpacity", "(", "element", ",", "opacity", ")", ";", "}" ]
Set the opacity of an element @param {HTMLElement} element @param {Number} opacity must be between 0 and 1
[ "Set", "the", "opacity", "of", "an", "element" ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Dom.js#L1242-L1247
train
ariatemplates/ariatemplates
src/aria/utils/Dom.js
function (domElt) { // work-around for http://crbug.com/240772 var values = []; var parent = domElt; while (parent && parent.style) { values.push(parent.style.cssText); parent.style.overflow = "hidden"; parent = parent.parentNode; } domElt.getBoundingClientRect(); // making sure Chrome updates the display parent = domElt; while (parent && parent.style) { parent.style.cssText = values.shift(); parent = parent.parentNode; } }
javascript
function (domElt) { // work-around for http://crbug.com/240772 var values = []; var parent = domElt; while (parent && parent.style) { values.push(parent.style.cssText); parent.style.overflow = "hidden"; parent = parent.parentNode; } domElt.getBoundingClientRect(); // making sure Chrome updates the display parent = domElt; while (parent && parent.style) { parent.style.cssText = values.shift(); parent = parent.parentNode; } }
[ "function", "(", "domElt", ")", "{", "var", "values", "=", "[", "]", ";", "var", "parent", "=", "domElt", ";", "while", "(", "parent", "&&", "parent", ".", "style", ")", "{", "values", ".", "push", "(", "parent", ".", "style", ".", "cssText", ")", ";", "parent", ".", "style", ".", "overflow", "=", "\"hidden\"", ";", "parent", "=", "parent", ".", "parentNode", ";", "}", "domElt", ".", "getBoundingClientRect", "(", ")", ";", "parent", "=", "domElt", ";", "while", "(", "parent", "&&", "parent", ".", "style", ")", "{", "parent", ".", "style", ".", "cssText", "=", "values", ".", "shift", "(", ")", ";", "parent", "=", "parent", ".", "parentNode", ";", "}", "}" ]
Refreshes scrollbars for the specified DOM element and all its parents. @see refreshScrollbars @param {HTMLElement} domElt
[ "Refreshes", "scrollbars", "for", "the", "specified", "DOM", "element", "and", "all", "its", "parents", "." ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Dom.js#L1274-L1289
train
ariatemplates/ariatemplates
src/aria/widgetLibs/BaseWidget.js
function (widget, msgArgs) { if (widget._context) { if (!msgArgs) { msgArgs = []; } msgArgs.unshift("Template: " + widget._context.tplClasspath + ", Line: " + widget._lineNumber + "\n"); } return msgArgs; }
javascript
function (widget, msgArgs) { if (widget._context) { if (!msgArgs) { msgArgs = []; } msgArgs.unshift("Template: " + widget._context.tplClasspath + ", Line: " + widget._lineNumber + "\n"); } return msgArgs; }
[ "function", "(", "widget", ",", "msgArgs", ")", "{", "if", "(", "widget", ".", "_context", ")", "{", "if", "(", "!", "msgArgs", ")", "{", "msgArgs", "=", "[", "]", ";", "}", "msgArgs", ".", "unshift", "(", "\"Template: \"", "+", "widget", ".", "_context", ".", "tplClasspath", "+", "\", Line: \"", "+", "widget", ".", "_lineNumber", "+", "\"\\n\"", ")", ";", "}", "\\n", "}" ]
Add template and line number information to the msgArgs array to be used for logs functions. Return the modified array. @param {aria.widgetLibs.BaseWidget} widget widget instance @param {Array} msgArgs array @return {Array} @private
[ "Add", "template", "and", "line", "number", "information", "to", "the", "msgArgs", "array", "to", "be", "used", "for", "logs", "functions", ".", "Return", "the", "modified", "array", "." ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgetLibs/BaseWidget.js#L33-L41
train
ariatemplates/ariatemplates
src/aria/widgetLibs/BaseWidget.js
function (id) { var dynamicIds = this._dynamicIds; if (dynamicIds) { var index = arrayUtils.indexOf(dynamicIds, id); if (index != -1) { idMgr.releaseId(id); if (dynamicIds.length == 1) { this._dynamicIds = null; } else { arrayUtils.removeAt(dynamicIds, index); } } } }
javascript
function (id) { var dynamicIds = this._dynamicIds; if (dynamicIds) { var index = arrayUtils.indexOf(dynamicIds, id); if (index != -1) { idMgr.releaseId(id); if (dynamicIds.length == 1) { this._dynamicIds = null; } else { arrayUtils.removeAt(dynamicIds, index); } } } }
[ "function", "(", "id", ")", "{", "var", "dynamicIds", "=", "this", ".", "_dynamicIds", ";", "if", "(", "dynamicIds", ")", "{", "var", "index", "=", "arrayUtils", ".", "indexOf", "(", "dynamicIds", ",", "id", ")", ";", "if", "(", "index", "!=", "-", "1", ")", "{", "idMgr", ".", "releaseId", "(", "id", ")", ";", "if", "(", "dynamicIds", ".", "length", "==", "1", ")", "{", "this", ".", "_dynamicIds", "=", "null", ";", "}", "else", "{", "arrayUtils", ".", "removeAt", "(", "dynamicIds", ",", "index", ")", ";", "}", "}", "}", "}" ]
Release a dynamic id created with _createDynamicId, so that it can be reused for another widget. If the id was not created with _createDynamicId or already released, the function does nothing. @param {String} id id to be released.
[ "Release", "a", "dynamic", "id", "created", "with", "_createDynamicId", "so", "that", "it", "can", "be", "reused", "for", "another", "widget", ".", "If", "the", "id", "was", "not", "created", "with", "_createDynamicId", "or", "already", "released", "the", "function", "does", "nothing", "." ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgetLibs/BaseWidget.js#L238-L251
train
ariatemplates/ariatemplates
src/aria/widgetLibs/BaseWidget.js
function () { var dynamicIds = this._dynamicIds; if (dynamicIds) { for (var i = dynamicIds.length - 1; i >= 0; i--) { idMgr.releaseId(dynamicIds[i]); } this._dynamicIds = null; } }
javascript
function () { var dynamicIds = this._dynamicIds; if (dynamicIds) { for (var i = dynamicIds.length - 1; i >= 0; i--) { idMgr.releaseId(dynamicIds[i]); } this._dynamicIds = null; } }
[ "function", "(", ")", "{", "var", "dynamicIds", "=", "this", ".", "_dynamicIds", ";", "if", "(", "dynamicIds", ")", "{", "for", "(", "var", "i", "=", "dynamicIds", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "idMgr", ".", "releaseId", "(", "dynamicIds", "[", "i", "]", ")", ";", "}", "this", ".", "_dynamicIds", "=", "null", ";", "}", "}" ]
Release all dynamic ids created with _createDynamicId, so that they can be reused for other widgets.
[ "Release", "all", "dynamic", "ids", "created", "with", "_createDynamicId", "so", "that", "they", "can", "be", "reused", "for", "other", "widgets", "." ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgetLibs/BaseWidget.js#L256-L264
train
ariatemplates/ariatemplates
src/aria/templates/MarkupWriter.js
function (m) { if (this._delegateMap) { if (m || m === 0) { // String cast m = '' + m; var closingIndex = m.indexOf(">"); if (closingIndex != -1) { var delegateMap = this._delegateMap; this._delegateMap = null; // delegate function that will call the good callback for the good event var handler = function (event) { var eventWrapper = new ariaTemplatesDomEventWrapper(event), result = true; var targetCallback = delegateMap[event.type]; if (targetCallback) { if (event.type == "safetap") { aria.touch.ClickBuster.registerTap(event); } result = targetCallback.call(eventWrapper); } eventWrapper.$dispose(); return result; }; var delegateId = ariaUtilsDelegate.add(handler); this._currentSection.delegateIds.push(delegateId); this._out.push(m.substring(0, closingIndex)); this._out.push(" " + ariaUtilsDelegate.getMarkup(delegateId)); this._out.push(m.substring(closingIndex)); return; } } } this._out.push(m); }
javascript
function (m) { if (this._delegateMap) { if (m || m === 0) { // String cast m = '' + m; var closingIndex = m.indexOf(">"); if (closingIndex != -1) { var delegateMap = this._delegateMap; this._delegateMap = null; // delegate function that will call the good callback for the good event var handler = function (event) { var eventWrapper = new ariaTemplatesDomEventWrapper(event), result = true; var targetCallback = delegateMap[event.type]; if (targetCallback) { if (event.type == "safetap") { aria.touch.ClickBuster.registerTap(event); } result = targetCallback.call(eventWrapper); } eventWrapper.$dispose(); return result; }; var delegateId = ariaUtilsDelegate.add(handler); this._currentSection.delegateIds.push(delegateId); this._out.push(m.substring(0, closingIndex)); this._out.push(" " + ariaUtilsDelegate.getMarkup(delegateId)); this._out.push(m.substring(closingIndex)); return; } } } this._out.push(m); }
[ "function", "(", "m", ")", "{", "if", "(", "this", ".", "_delegateMap", ")", "{", "if", "(", "m", "||", "m", "===", "0", ")", "{", "m", "=", "''", "+", "m", ";", "var", "closingIndex", "=", "m", ".", "indexOf", "(", "\">\"", ")", ";", "if", "(", "closingIndex", "!=", "-", "1", ")", "{", "var", "delegateMap", "=", "this", ".", "_delegateMap", ";", "this", ".", "_delegateMap", "=", "null", ";", "var", "handler", "=", "function", "(", "event", ")", "{", "var", "eventWrapper", "=", "new", "ariaTemplatesDomEventWrapper", "(", "event", ")", ",", "result", "=", "true", ";", "var", "targetCallback", "=", "delegateMap", "[", "event", ".", "type", "]", ";", "if", "(", "targetCallback", ")", "{", "if", "(", "event", ".", "type", "==", "\"safetap\"", ")", "{", "aria", ".", "touch", ".", "ClickBuster", ".", "registerTap", "(", "event", ")", ";", "}", "result", "=", "targetCallback", ".", "call", "(", "eventWrapper", ")", ";", "}", "eventWrapper", ".", "$dispose", "(", ")", ";", "return", "result", ";", "}", ";", "var", "delegateId", "=", "ariaUtilsDelegate", ".", "add", "(", "handler", ")", ";", "this", ".", "_currentSection", ".", "delegateIds", ".", "push", "(", "delegateId", ")", ";", "this", ".", "_out", ".", "push", "(", "m", ".", "substring", "(", "0", ",", "closingIndex", ")", ")", ";", "this", ".", "_out", ".", "push", "(", "\" \"", "+", "ariaUtilsDelegate", ".", "getMarkup", "(", "delegateId", ")", ")", ";", "this", ".", "_out", ".", "push", "(", "m", ".", "substring", "(", "closingIndex", ")", ")", ";", "return", ";", "}", "}", "}", "this", ".", "_out", ".", "push", "(", "m", ")", ";", "}" ]
Put markup in current output stream @param {String} m the HTML markup to write in the current output
[ "Put", "markup", "in", "current", "output", "stream" ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/templates/MarkupWriter.js#L163-L197
train
ariatemplates/ariatemplates
src/aria/templates/MarkupWriter.js
function (event) { var eventWrapper = new ariaTemplatesDomEventWrapper(event), result = true; var targetCallback = delegateMap[event.type]; if (targetCallback) { if (event.type == "safetap") { aria.touch.ClickBuster.registerTap(event); } result = targetCallback.call(eventWrapper); } eventWrapper.$dispose(); return result; }
javascript
function (event) { var eventWrapper = new ariaTemplatesDomEventWrapper(event), result = true; var targetCallback = delegateMap[event.type]; if (targetCallback) { if (event.type == "safetap") { aria.touch.ClickBuster.registerTap(event); } result = targetCallback.call(eventWrapper); } eventWrapper.$dispose(); return result; }
[ "function", "(", "event", ")", "{", "var", "eventWrapper", "=", "new", "ariaTemplatesDomEventWrapper", "(", "event", ")", ",", "result", "=", "true", ";", "var", "targetCallback", "=", "delegateMap", "[", "event", ".", "type", "]", ";", "if", "(", "targetCallback", ")", "{", "if", "(", "event", ".", "type", "==", "\"safetap\"", ")", "{", "aria", ".", "touch", ".", "ClickBuster", ".", "registerTap", "(", "event", ")", ";", "}", "result", "=", "targetCallback", ".", "call", "(", "eventWrapper", ")", ";", "}", "eventWrapper", ".", "$dispose", "(", ")", ";", "return", "result", ";", "}" ]
delegate function that will call the good callback for the good event
[ "delegate", "function", "that", "will", "call", "the", "good", "callback", "for", "the", "good", "event" ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/templates/MarkupWriter.js#L173-L184
train
ariatemplates/ariatemplates
src/aria/templates/MarkupWriter.js
function (eventName, callback) { // do nothing if no section is defined (partial refresh usecase) if (!this._currentSection) { return; } var delegate = ariaUtilsDelegate; // Fallback mechanism for event that can not be delegated if (!delegate.isDelegated(eventName)) { var delegateId = delegate.add(callback); this._currentSection.delegateIds.push(delegateId); this.write(delegate.getFallbackMarkup(eventName, delegateId, true)); return; } // transform callback description into a new callback that will be use by the function doing dispatch callback = new aria.utils.Callback(callback); this._currentSection.delegateCallbacks.push(callback); if (!this._delegateMap) { this._delegateMap = {}; } this._delegateMap[eventName] = callback; }
javascript
function (eventName, callback) { // do nothing if no section is defined (partial refresh usecase) if (!this._currentSection) { return; } var delegate = ariaUtilsDelegate; // Fallback mechanism for event that can not be delegated if (!delegate.isDelegated(eventName)) { var delegateId = delegate.add(callback); this._currentSection.delegateIds.push(delegateId); this.write(delegate.getFallbackMarkup(eventName, delegateId, true)); return; } // transform callback description into a new callback that will be use by the function doing dispatch callback = new aria.utils.Callback(callback); this._currentSection.delegateCallbacks.push(callback); if (!this._delegateMap) { this._delegateMap = {}; } this._delegateMap[eventName] = callback; }
[ "function", "(", "eventName", ",", "callback", ")", "{", "if", "(", "!", "this", ".", "_currentSection", ")", "{", "return", ";", "}", "var", "delegate", "=", "ariaUtilsDelegate", ";", "if", "(", "!", "delegate", ".", "isDelegated", "(", "eventName", ")", ")", "{", "var", "delegateId", "=", "delegate", ".", "add", "(", "callback", ")", ";", "this", ".", "_currentSection", ".", "delegateIds", ".", "push", "(", "delegateId", ")", ";", "this", ".", "write", "(", "delegate", ".", "getFallbackMarkup", "(", "eventName", ",", "delegateId", ",", "true", ")", ")", ";", "return", ";", "}", "callback", "=", "new", "aria", ".", "utils", ".", "Callback", "(", "callback", ")", ";", "this", ".", "_currentSection", ".", "delegateCallbacks", ".", "push", "(", "callback", ")", ";", "if", "(", "!", "this", ".", "_delegateMap", ")", "{", "this", ".", "_delegateMap", "=", "{", "}", ";", "}", "this", ".", "_delegateMap", "[", "eventName", "]", "=", "callback", ";", "}" ]
Add a delegate function on current markup @param {String} eventName @param {aria.core.CfgBeans:Callback} callback
[ "Add", "a", "delegate", "function", "on", "current", "markup" ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/templates/MarkupWriter.js#L204-L231
train
ariatemplates/ariatemplates
src/aria/templates/MarkupWriter.js
function () { var res = this._topSection; res.html = this._out.join(""); this._delegate = null; this._out = null; this._topSection = null; // so that the section is not disposed in the MarkupWriter destructor return res; }
javascript
function () { var res = this._topSection; res.html = this._out.join(""); this._delegate = null; this._out = null; this._topSection = null; // so that the section is not disposed in the MarkupWriter destructor return res; }
[ "function", "(", ")", "{", "var", "res", "=", "this", ".", "_topSection", ";", "res", ".", "html", "=", "this", ".", "_out", ".", "join", "(", "\"\"", ")", ";", "this", ".", "_delegate", "=", "null", ";", "this", ".", "_out", "=", "null", ";", "this", ".", "_topSection", "=", "null", ";", "return", "res", ";", "}" ]
Return the top section. In the context of a partial refresh, this will be the section to refresh only @return {aria.templates.Section}
[ "Return", "the", "top", "section", ".", "In", "the", "context", "of", "a", "partial", "refresh", "this", "will", "be", "the", "section", "to", "refresh", "only" ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/templates/MarkupWriter.js#L255-L262
train
ariatemplates/ariatemplates
src/aria/widgets/action/Link.js
function (domEvt) { if (domEvt.keyCode == aria.DomEvent.KC_ENTER) { if (this._keyPressed) { this._keyPressed = false; if (!this._performAction(domEvt)) { domEvt.stopPropagation(); return false; } } } return true; }
javascript
function (domEvt) { if (domEvt.keyCode == aria.DomEvent.KC_ENTER) { if (this._keyPressed) { this._keyPressed = false; if (!this._performAction(domEvt)) { domEvt.stopPropagation(); return false; } } } return true; }
[ "function", "(", "domEvt", ")", "{", "if", "(", "domEvt", ".", "keyCode", "==", "aria", ".", "DomEvent", ".", "KC_ENTER", ")", "{", "if", "(", "this", ".", "_keyPressed", ")", "{", "this", ".", "_keyPressed", "=", "false", ";", "if", "(", "!", "this", ".", "_performAction", "(", "domEvt", ")", ")", "{", "domEvt", ".", "stopPropagation", "(", ")", ";", "return", "false", ";", "}", "}", "}", "return", "true", ";", "}" ]
React to delegated key up events @protected @param {aria.DomEvent} domEvt Event
[ "React", "to", "delegated", "key", "up", "events" ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/action/Link.js#L129-L140
train
ariatemplates/ariatemplates
src/aria/templates/Layout.js
function () { if (__scrollBarsWidth != null) { return __scrollBarsWidth; } var document = Aria.$window.document; var o = document.createElement("div"); // outer div var i = document.createElement("div"); // inner div o.style.overflow = ""; o.style.position = "absolute"; o.style.left = "-10000px"; o.style.top = "-10000px"; o.style.width = "500px"; o.style.height = "500px"; // Old solution with width 100% seems to behave correctly // for all browsers except IE7. Some research gives that // just for IE7 this method does not work when setting width 100%, // but works correctly setting no width if (!ariaCoreBrowser.isIE7) { i.style.width = "100%"; } i.style.height = "100%"; document.body.appendChild(o); o.appendChild(i); __scrollBarsWidth = i.offsetWidth; o.style.overflow = "scroll"; __scrollBarsWidth -= i.offsetWidth; document.body.removeChild(o); return __scrollBarsWidth; }
javascript
function () { if (__scrollBarsWidth != null) { return __scrollBarsWidth; } var document = Aria.$window.document; var o = document.createElement("div"); // outer div var i = document.createElement("div"); // inner div o.style.overflow = ""; o.style.position = "absolute"; o.style.left = "-10000px"; o.style.top = "-10000px"; o.style.width = "500px"; o.style.height = "500px"; // Old solution with width 100% seems to behave correctly // for all browsers except IE7. Some research gives that // just for IE7 this method does not work when setting width 100%, // but works correctly setting no width if (!ariaCoreBrowser.isIE7) { i.style.width = "100%"; } i.style.height = "100%"; document.body.appendChild(o); o.appendChild(i); __scrollBarsWidth = i.offsetWidth; o.style.overflow = "scroll"; __scrollBarsWidth -= i.offsetWidth; document.body.removeChild(o); return __scrollBarsWidth; }
[ "function", "(", ")", "{", "if", "(", "__scrollBarsWidth", "!=", "null", ")", "{", "return", "__scrollBarsWidth", ";", "}", "var", "document", "=", "Aria", ".", "$window", ".", "document", ";", "var", "o", "=", "document", ".", "createElement", "(", "\"div\"", ")", ";", "var", "i", "=", "document", ".", "createElement", "(", "\"div\"", ")", ";", "o", ".", "style", ".", "overflow", "=", "\"\"", ";", "o", ".", "style", ".", "position", "=", "\"absolute\"", ";", "o", ".", "style", ".", "left", "=", "\"-10000px\"", ";", "o", ".", "style", ".", "top", "=", "\"-10000px\"", ";", "o", ".", "style", ".", "width", "=", "\"500px\"", ";", "o", ".", "style", ".", "height", "=", "\"500px\"", ";", "if", "(", "!", "ariaCoreBrowser", ".", "isIE7", ")", "{", "i", ".", "style", ".", "width", "=", "\"100%\"", ";", "}", "i", ".", "style", ".", "height", "=", "\"100%\"", ";", "document", ".", "body", ".", "appendChild", "(", "o", ")", ";", "o", ".", "appendChild", "(", "i", ")", ";", "__scrollBarsWidth", "=", "i", ".", "offsetWidth", ";", "o", ".", "style", ".", "overflow", "=", "\"scroll\"", ";", "__scrollBarsWidth", "-=", "i", ".", "offsetWidth", ";", "document", ".", "body", ".", "removeChild", "(", "o", ")", ";", "return", "__scrollBarsWidth", ";", "}" ]
Returns the width of scrollbars in pixels, as measured in the current browser. @return {Number}
[ "Returns", "the", "width", "of", "scrollbars", "in", "pixels", "as", "measured", "in", "the", "current", "browser", "." ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/templates/Layout.js#L352-L380
train
ariatemplates/ariatemplates
src/aria/core/transport/IFrame.js
function (request) { var iFrame; var browser = ariaCoreBrowser; var document = Aria.$frameworkWindow.document; // Issue when using document.createElement("iframe") in IE7 if (browser.isIE7) { var container = document.createElement("div"); container.innerHTML = ['<iframe style="display:none" src="', ariaCoreDownloadMgr.resolveURL("aria/core/transport/iframeSource.txt"), '" id="xIFrame', request.id, '" name="xIFrame', request.id, '"></iframe>'].join(''); document.body.appendChild(container); iFrame = document.getElementById("xIFrame" + request.id); request.iFrameContainer = container; } else { iFrame = document.createElement("iframe"); iFrame.src = ariaCoreDownloadMgr.resolveURL("aria/core/transport/iframeSource.txt"); iFrame.id = iFrame.name = "xIFrame" + request.id; iFrame.style.cssText = "display:none"; document.body.appendChild(iFrame); } request.iFrame = iFrame; // Event handlers iFrame.onload = iFrame.onreadystatechange = this._iFrameReady; }
javascript
function (request) { var iFrame; var browser = ariaCoreBrowser; var document = Aria.$frameworkWindow.document; // Issue when using document.createElement("iframe") in IE7 if (browser.isIE7) { var container = document.createElement("div"); container.innerHTML = ['<iframe style="display:none" src="', ariaCoreDownloadMgr.resolveURL("aria/core/transport/iframeSource.txt"), '" id="xIFrame', request.id, '" name="xIFrame', request.id, '"></iframe>'].join(''); document.body.appendChild(container); iFrame = document.getElementById("xIFrame" + request.id); request.iFrameContainer = container; } else { iFrame = document.createElement("iframe"); iFrame.src = ariaCoreDownloadMgr.resolveURL("aria/core/transport/iframeSource.txt"); iFrame.id = iFrame.name = "xIFrame" + request.id; iFrame.style.cssText = "display:none"; document.body.appendChild(iFrame); } request.iFrame = iFrame; // Event handlers iFrame.onload = iFrame.onreadystatechange = this._iFrameReady; }
[ "function", "(", "request", ")", "{", "var", "iFrame", ";", "var", "browser", "=", "ariaCoreBrowser", ";", "var", "document", "=", "Aria", ".", "$frameworkWindow", ".", "document", ";", "if", "(", "browser", ".", "isIE7", ")", "{", "var", "container", "=", "document", ".", "createElement", "(", "\"div\"", ")", ";", "container", ".", "innerHTML", "=", "[", "'<iframe style=\"display:none\" src=\"'", ",", "ariaCoreDownloadMgr", ".", "resolveURL", "(", "\"aria/core/transport/iframeSource.txt\"", ")", ",", "'\" id=\"xIFrame'", ",", "request", ".", "id", ",", "'\" name=\"xIFrame'", ",", "request", ".", "id", ",", "'\"></iframe>'", "]", ".", "join", "(", "''", ")", ";", "document", ".", "body", ".", "appendChild", "(", "container", ")", ";", "iFrame", "=", "document", ".", "getElementById", "(", "\"xIFrame\"", "+", "request", ".", "id", ")", ";", "request", ".", "iFrameContainer", "=", "container", ";", "}", "else", "{", "iFrame", "=", "document", ".", "createElement", "(", "\"iframe\"", ")", ";", "iFrame", ".", "src", "=", "ariaCoreDownloadMgr", ".", "resolveURL", "(", "\"aria/core/transport/iframeSource.txt\"", ")", ";", "iFrame", ".", "id", "=", "iFrame", ".", "name", "=", "\"xIFrame\"", "+", "request", ".", "id", ";", "iFrame", ".", "style", ".", "cssText", "=", "\"display:none\"", ";", "document", ".", "body", ".", "appendChild", "(", "iFrame", ")", ";", "}", "request", ".", "iFrame", "=", "iFrame", ";", "iFrame", ".", "onload", "=", "iFrame", ".", "onreadystatechange", "=", "this", ".", "_iFrameReady", ";", "}" ]
Creates an iFrame to load the response of the request. @param {aria.core.CfgBeans:IOAsyncRequestCfg} request @protected
[ "Creates", "an", "iFrame", "to", "load", "the", "response", "of", "the", "request", "." ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/transport/IFrame.js#L75-L100
train
ariatemplates/ariatemplates
src/aria/core/transport/IFrame.js
function (request, callback) { var form = request.form; form.target = "xIFrame" + request.id; form.action = request.url; form.method = request.method; if (request.headers["Content-Type"]) { try { // in IE 8, setting form.enctype directly does not work // form.setAttribute works better (check PTR 07049566) form.setAttribute("enctype", request.headers["Content-Type"]); } catch (ex) { // This might throw an exception in IE if the content type is invalid. } } try { form.submit(); } catch (er) { this.$logError(this.ERROR_DURING_SUBMIT, null, er); this._deleteRequest(request); ariaCoreIO._handleTransactionResponse({ conn : { status : 0, responseText : null, getAllResponseHeaders : function () {} }, transaction : request.id }, callback, true); } }
javascript
function (request, callback) { var form = request.form; form.target = "xIFrame" + request.id; form.action = request.url; form.method = request.method; if (request.headers["Content-Type"]) { try { // in IE 8, setting form.enctype directly does not work // form.setAttribute works better (check PTR 07049566) form.setAttribute("enctype", request.headers["Content-Type"]); } catch (ex) { // This might throw an exception in IE if the content type is invalid. } } try { form.submit(); } catch (er) { this.$logError(this.ERROR_DURING_SUBMIT, null, er); this._deleteRequest(request); ariaCoreIO._handleTransactionResponse({ conn : { status : 0, responseText : null, getAllResponseHeaders : function () {} }, transaction : request.id }, callback, true); } }
[ "function", "(", "request", ",", "callback", ")", "{", "var", "form", "=", "request", ".", "form", ";", "form", ".", "target", "=", "\"xIFrame\"", "+", "request", ".", "id", ";", "form", ".", "action", "=", "request", ".", "url", ";", "form", ".", "method", "=", "request", ".", "method", ";", "if", "(", "request", ".", "headers", "[", "\"Content-Type\"", "]", ")", "{", "try", "{", "form", ".", "setAttribute", "(", "\"enctype\"", ",", "request", ".", "headers", "[", "\"Content-Type\"", "]", ")", ";", "}", "catch", "(", "ex", ")", "{", "}", "}", "try", "{", "form", ".", "submit", "(", ")", ";", "}", "catch", "(", "er", ")", "{", "this", ".", "$logError", "(", "this", ".", "ERROR_DURING_SUBMIT", ",", "null", ",", "er", ")", ";", "this", ".", "_deleteRequest", "(", "request", ")", ";", "ariaCoreIO", ".", "_handleTransactionResponse", "(", "{", "conn", ":", "{", "status", ":", "0", ",", "responseText", ":", "null", ",", "getAllResponseHeaders", ":", "function", "(", ")", "{", "}", "}", ",", "transaction", ":", "request", ".", "id", "}", ",", "callback", ",", "true", ")", ";", "}", "}" ]
Updates the form to target the iframe then calls the forms submit method. @param {aria.core.CfgBeans:IOAsyncRequestCfg} request @param {Object} callback Internal callback description @protected
[ "Updates", "the", "form", "to", "target", "the", "iframe", "then", "calls", "the", "forms", "submit", "method", "." ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/transport/IFrame.js#L108-L136
train
ariatemplates/ariatemplates
src/aria/core/transport/IFrame.js
function (event) { // This method cannot use 'this' because the scope is not aria.core.transport.IFrame when this method is // called. It uses oSelf instead. var event = event || Aria.$frameworkWindow.event; var iFrame = event.target || event.srcElement; if (!iFrame.readyState || /loaded|complete/.test(iFrame.readyState)) { var reqId = /^xIFrame(\d+)$/.exec(iFrame.id)[1]; // Make sure things are async setTimeout(function () { aria.core.transport.IFrame._sendBackResult(reqId); }, 4); } }
javascript
function (event) { // This method cannot use 'this' because the scope is not aria.core.transport.IFrame when this method is // called. It uses oSelf instead. var event = event || Aria.$frameworkWindow.event; var iFrame = event.target || event.srcElement; if (!iFrame.readyState || /loaded|complete/.test(iFrame.readyState)) { var reqId = /^xIFrame(\d+)$/.exec(iFrame.id)[1]; // Make sure things are async setTimeout(function () { aria.core.transport.IFrame._sendBackResult(reqId); }, 4); } }
[ "function", "(", "event", ")", "{", "var", "event", "=", "event", "||", "Aria", ".", "$frameworkWindow", ".", "event", ";", "var", "iFrame", "=", "event", ".", "target", "||", "event", ".", "srcElement", ";", "if", "(", "!", "iFrame", ".", "readyState", "||", "/", "loaded|complete", "/", ".", "test", "(", "iFrame", ".", "readyState", ")", ")", "{", "var", "reqId", "=", "/", "^xIFrame(\\d+)$", "/", ".", "exec", "(", "iFrame", ".", "id", ")", "[", "1", "]", ";", "setTimeout", "(", "function", "(", ")", "{", "aria", ".", "core", ".", "transport", ".", "IFrame", ".", "_sendBackResult", "(", "reqId", ")", ";", "}", ",", "4", ")", ";", "}", "}" ]
load and readystatechange event handler on the iFrame. @param {DOMEvent} event
[ "load", "and", "readystatechange", "event", "handler", "on", "the", "iFrame", "." ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/transport/IFrame.js#L142-L154
train
ariatemplates/ariatemplates
src/aria/core/transport/IFrame.js
function (id) { var description = this._requests[id]; if (!description) { // The request was aborted return; } var request = description.request; var callback = description.cb; var iFrame = request.iFrame; var responseText, contentDocument = iFrame.contentDocument, contentWindow; if (contentDocument == null) { var contentWindow = iFrame.contentWindow; if (contentWindow) { contentDocument = contentWindow.document; } } if (contentDocument) { var body = contentDocument.body || contentDocument.documentElement; if (body) { // this is for content displayed as text: responseText = body.textContent || body.outerText; } var xmlDoc = contentDocument.XMLDocument; // In IE, contentDocument contains a transformation of the document // see: http://www.aspnet-answers.com/microsoft/JScript/29847637/javascript-ie-xml.aspx if (xmlDoc) { contentDocument = xmlDoc; } } this._deleteRequest(request); var response = { status : 200, responseText : responseText, responseXML : contentDocument }; callback.fn.call(callback.scope, false, callback.args, response); }
javascript
function (id) { var description = this._requests[id]; if (!description) { // The request was aborted return; } var request = description.request; var callback = description.cb; var iFrame = request.iFrame; var responseText, contentDocument = iFrame.contentDocument, contentWindow; if (contentDocument == null) { var contentWindow = iFrame.contentWindow; if (contentWindow) { contentDocument = contentWindow.document; } } if (contentDocument) { var body = contentDocument.body || contentDocument.documentElement; if (body) { // this is for content displayed as text: responseText = body.textContent || body.outerText; } var xmlDoc = contentDocument.XMLDocument; // In IE, contentDocument contains a transformation of the document // see: http://www.aspnet-answers.com/microsoft/JScript/29847637/javascript-ie-xml.aspx if (xmlDoc) { contentDocument = xmlDoc; } } this._deleteRequest(request); var response = { status : 200, responseText : responseText, responseXML : contentDocument }; callback.fn.call(callback.scope, false, callback.args, response); }
[ "function", "(", "id", ")", "{", "var", "description", "=", "this", ".", "_requests", "[", "id", "]", ";", "if", "(", "!", "description", ")", "{", "return", ";", "}", "var", "request", "=", "description", ".", "request", ";", "var", "callback", "=", "description", ".", "cb", ";", "var", "iFrame", "=", "request", ".", "iFrame", ";", "var", "responseText", ",", "contentDocument", "=", "iFrame", ".", "contentDocument", ",", "contentWindow", ";", "if", "(", "contentDocument", "==", "null", ")", "{", "var", "contentWindow", "=", "iFrame", ".", "contentWindow", ";", "if", "(", "contentWindow", ")", "{", "contentDocument", "=", "contentWindow", ".", "document", ";", "}", "}", "if", "(", "contentDocument", ")", "{", "var", "body", "=", "contentDocument", ".", "body", "||", "contentDocument", ".", "documentElement", ";", "if", "(", "body", ")", "{", "responseText", "=", "body", ".", "textContent", "||", "body", ".", "outerText", ";", "}", "var", "xmlDoc", "=", "contentDocument", ".", "XMLDocument", ";", "if", "(", "xmlDoc", ")", "{", "contentDocument", "=", "xmlDoc", ";", "}", "}", "this", ".", "_deleteRequest", "(", "request", ")", ";", "var", "response", "=", "{", "status", ":", "200", ",", "responseText", ":", "responseText", ",", "responseXML", ":", "contentDocument", "}", ";", "callback", ".", "fn", ".", "call", "(", "callback", ".", "scope", ",", "false", ",", "callback", ".", "args", ",", "response", ")", ";", "}" ]
Sends back the results of the request @param {String} id Request id @protected
[ "Sends", "back", "the", "results", "of", "the", "request" ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/transport/IFrame.js#L161-L202
train
ariatemplates/ariatemplates
src/aria/core/transport/IFrame.js
function (request) { var iFrame = request.iFrame; if (iFrame) { var domEltToRemove = request.iFrameContainer || iFrame; domEltToRemove.parentNode.removeChild(domEltToRemove); // avoid leaks: request.iFrameContainer = null; request.iFrame = null; iFrame.onload = null; iFrame.onreadystatechange = null; } delete this._requests[request.id]; }
javascript
function (request) { var iFrame = request.iFrame; if (iFrame) { var domEltToRemove = request.iFrameContainer || iFrame; domEltToRemove.parentNode.removeChild(domEltToRemove); // avoid leaks: request.iFrameContainer = null; request.iFrame = null; iFrame.onload = null; iFrame.onreadystatechange = null; } delete this._requests[request.id]; }
[ "function", "(", "request", ")", "{", "var", "iFrame", "=", "request", ".", "iFrame", ";", "if", "(", "iFrame", ")", "{", "var", "domEltToRemove", "=", "request", ".", "iFrameContainer", "||", "iFrame", ";", "domEltToRemove", ".", "parentNode", ".", "removeChild", "(", "domEltToRemove", ")", ";", "request", ".", "iFrameContainer", "=", "null", ";", "request", ".", "iFrame", "=", "null", ";", "iFrame", ".", "onload", "=", "null", ";", "iFrame", ".", "onreadystatechange", "=", "null", ";", "}", "delete", "this", ".", "_requests", "[", "request", ".", "id", "]", ";", "}" ]
Delete a request freing up memory @param {aria.core.CfgBeans:IOAsyncRequestCfg} request
[ "Delete", "a", "request", "freing", "up", "memory" ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/transport/IFrame.js#L208-L220
train
ariatemplates/ariatemplates
src/aria/utils/Callback.js
function (evt) { var args = (this._apply === true && ariaUtilsType.isArray(this._args)) ? this._args.slice() : [this._args]; var resIndex = (this._resIndex === undefined) ? 0 : this._resIndex; if (resIndex > -1) { args.splice(resIndex, 0, evt); } return this._function.apply(this._scope, args); }
javascript
function (evt) { var args = (this._apply === true && ariaUtilsType.isArray(this._args)) ? this._args.slice() : [this._args]; var resIndex = (this._resIndex === undefined) ? 0 : this._resIndex; if (resIndex > -1) { args.splice(resIndex, 0, evt); } return this._function.apply(this._scope, args); }
[ "function", "(", "evt", ")", "{", "var", "args", "=", "(", "this", ".", "_apply", "===", "true", "&&", "ariaUtilsType", ".", "isArray", "(", "this", ".", "_args", ")", ")", "?", "this", ".", "_args", ".", "slice", "(", ")", ":", "[", "this", ".", "_args", "]", ";", "var", "resIndex", "=", "(", "this", ".", "_resIndex", "===", "undefined", ")", "?", "0", ":", "this", ".", "_resIndex", ";", "if", "(", "resIndex", ">", "-", "1", ")", "{", "args", ".", "splice", "(", "resIndex", ",", "0", ",", "evt", ")", ";", "}", "return", "this", ".", "_function", ".", "apply", "(", "this", ".", "_scope", ",", "args", ")", ";", "}" ]
Execute the callback. It is equivalent to Callback.apply @param {Object} event
[ "Execute", "the", "callback", ".", "It", "is", "equivalent", "to", "Callback", ".", "apply" ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Callback.js#L160-L169
train
ariatemplates/ariatemplates
src/aria/widgets/container/Fieldset.js
function (domEvt) { if (domEvt.keyCode == domEvt.KC_ENTER) { if (this._checkTargetBeforeSubmit(domEvt.target)) { var onSubmit = this._cfg.onSubmit; if (onSubmit) { return this.evalCallback(this._cfg.onSubmit) === true; } } } }
javascript
function (domEvt) { if (domEvt.keyCode == domEvt.KC_ENTER) { if (this._checkTargetBeforeSubmit(domEvt.target)) { var onSubmit = this._cfg.onSubmit; if (onSubmit) { return this.evalCallback(this._cfg.onSubmit) === true; } } } }
[ "function", "(", "domEvt", ")", "{", "if", "(", "domEvt", ".", "keyCode", "==", "domEvt", ".", "KC_ENTER", ")", "{", "if", "(", "this", ".", "_checkTargetBeforeSubmit", "(", "domEvt", ".", "target", ")", ")", "{", "var", "onSubmit", "=", "this", ".", "_cfg", ".", "onSubmit", ";", "if", "(", "onSubmit", ")", "{", "return", "this", ".", "evalCallback", "(", "this", ".", "_cfg", ".", "onSubmit", ")", "===", "true", ";", "}", "}", "}", "}" ]
Called from the DOM when a key is pressed inside the fieldset. @param {aria.DomEvent} domEvt event @protected
[ "Called", "from", "the", "DOM", "when", "a", "key", "is", "pressed", "inside", "the", "fieldset", "." ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/container/Fieldset.js#L99-L108
train
ariatemplates/ariatemplates
src/aria/widgets/container/Fieldset.js
function (out) { var label = this._cfg.label; if (label && this._cfg.waiAria) { out.write('<span class="xSROnly">' + ariaUtilsString.escapeHTML(label) + '</span>'); } this._frame.writeMarkupBegin(out); }
javascript
function (out) { var label = this._cfg.label; if (label && this._cfg.waiAria) { out.write('<span class="xSROnly">' + ariaUtilsString.escapeHTML(label) + '</span>'); } this._frame.writeMarkupBegin(out); }
[ "function", "(", "out", ")", "{", "var", "label", "=", "this", ".", "_cfg", ".", "label", ";", "if", "(", "label", "&&", "this", ".", "_cfg", ".", "waiAria", ")", "{", "out", ".", "write", "(", "'<span class=\"xSROnly\">'", "+", "ariaUtilsString", ".", "escapeHTML", "(", "label", ")", "+", "'</span>'", ")", ";", "}", "this", ".", "_frame", ".", "writeMarkupBegin", "(", "out", ")", ";", "}" ]
Generate the internal widget begin markup @param {aria.templates.MarkupWriter} out the writer Object to use to output markup @protected
[ "Generate", "the", "internal", "widget", "begin", "markup" ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/container/Fieldset.js#L115-L121
train
ariatemplates/ariatemplates
src/aria/widgets/container/Fieldset.js
function (out) { this._frame.writeMarkupEnd(out); var label = this._cfg.label; if (label) { var ariaHidden = this._cfg.waiAria ? ' aria-hidden="true"' : ''; out.write('<span class="xFieldset_' + this._cfg.sclass + '_normal_label"' + ariaHidden + '>' + ariaUtilsString.escapeHTML(label) + '</span>'); } }
javascript
function (out) { this._frame.writeMarkupEnd(out); var label = this._cfg.label; if (label) { var ariaHidden = this._cfg.waiAria ? ' aria-hidden="true"' : ''; out.write('<span class="xFieldset_' + this._cfg.sclass + '_normal_label"' + ariaHidden + '>' + ariaUtilsString.escapeHTML(label) + '</span>'); } }
[ "function", "(", "out", ")", "{", "this", ".", "_frame", ".", "writeMarkupEnd", "(", "out", ")", ";", "var", "label", "=", "this", ".", "_cfg", ".", "label", ";", "if", "(", "label", ")", "{", "var", "ariaHidden", "=", "this", ".", "_cfg", ".", "waiAria", "?", "' aria-hidden=\"true\"'", ":", "''", ";", "out", ".", "write", "(", "'<span class=\"xFieldset_'", "+", "this", ".", "_cfg", ".", "sclass", "+", "'_normal_label\"'", "+", "ariaHidden", "+", "'>'", "+", "ariaUtilsString", ".", "escapeHTML", "(", "label", ")", "+", "'</span>'", ")", ";", "}", "}" ]
Generate the internal widget end markup @param {aria.templates.MarkupWriter} out the writer Object to use to output markup @protected
[ "Generate", "the", "internal", "widget", "end", "markup" ]
7ed5d065818ae159bf361c9dfb209b1cf3883c90
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/container/Fieldset.js#L128-L135
train