_id
stringlengths 2
6
| title
stringlengths 0
58
| partition
stringclasses 3
values | text
stringlengths 52
373k
| language
stringclasses 1
value | meta_information
dict |
|---|---|---|---|---|---|
q56600
|
finishedInstall
|
train
|
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
|
{
"resource": ""
}
|
q56601
|
setFilters
|
train
|
function setFilters(swig, filters) {
for (var name in filters) {
swig.setFilter(name, filters[name]);
}
}
|
javascript
|
{
"resource": ""
}
|
q56602
|
setTags
|
train
|
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
|
{
"resource": ""
}
|
q56603
|
setExtensions
|
train
|
function setExtensions(swig, extensions) {
for (var name in extensions) {
swig.setExtension(name, extensions[name]);
}
}
|
javascript
|
{
"resource": ""
}
|
q56604
|
train
|
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
|
{
"resource": ""
}
|
|
q56605
|
configContext
|
train
|
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
|
{
"resource": ""
}
|
q56606
|
train
|
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
|
{
"resource": ""
}
|
|
q56607
|
getInstalledPathSync
|
train
|
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
|
{
"resource": ""
}
|
q56608
|
DragTabs
|
train
|
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
|
{
"resource": ""
}
|
q56609
|
SMTPPool
|
train
|
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
|
{
"resource": ""
}
|
q56610
|
PoolResource
|
train
|
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
|
{
"resource": ""
}
|
q56611
|
addReverseLookupsForExtendeds
|
train
|
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
|
{
"resource": ""
}
|
q56612
|
dist_p_sep
|
train
|
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
|
{
"resource": ""
}
|
q56613
|
predictOneDT
|
train
|
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
|
{
"resource": ""
}
|
q56614
|
entropy
|
train
|
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
|
{
"resource": ""
}
|
q56615
|
initConfig
|
train
|
function initConfig(conf) {
const result = Object.assign({}, conf);
if (conf.filename) {
result.filepath = path.dirname(conf.filename);
}
return result;
}
|
javascript
|
{
"resource": ""
}
|
q56616
|
lookupFile
|
train
|
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
|
{
"resource": ""
}
|
q56617
|
train
|
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
|
{
"resource": ""
}
|
|
q56618
|
isReactElement
|
train
|
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
|
{
"resource": ""
}
|
q56619
|
initialize
|
train
|
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
|
{
"resource": ""
}
|
q56620
|
open
|
train
|
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
|
{
"resource": ""
}
|
q56621
|
destroy
|
train
|
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
|
{
"resource": ""
}
|
q56622
|
trimActions
|
train
|
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
|
{
"resource": ""
}
|
q56623
|
getBrowserName
|
train
|
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
|
{
"resource": ""
}
|
q56624
|
defaultWorkflow
|
train
|
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
|
{
"resource": ""
}
|
q56625
|
filterFilesForUnchangedTasks
|
train
|
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
|
{
"resource": ""
}
|
q56626
|
Struct
|
train
|
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
|
{
"resource": ""
}
|
q56627
|
StructType
|
train
|
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
|
{
"resource": ""
}
|
q56628
|
set
|
train
|
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
|
{
"resource": ""
}
|
q56629
|
train
|
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
|
{
"resource": ""
}
|
|
q56630
|
train
|
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
|
{
"resource": ""
}
|
|
q56631
|
train
|
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
|
{
"resource": ""
}
|
|
q56632
|
train
|
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
|
{
"resource": ""
}
|
|
q56633
|
train
|
function (newValue) {
var barEl = this.getDom().childNodes[0];
if (barEl !== null) {
barEl.innerHTML = newValue;
}
barEl = null;
}
|
javascript
|
{
"resource": ""
}
|
|
q56634
|
train
|
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
|
{
"resource": ""
}
|
|
q56635
|
train
|
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
|
{
"resource": ""
}
|
|
q56636
|
train
|
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
|
{
"resource": ""
}
|
|
q56637
|
PromisedHandler
|
train
|
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
|
{
"resource": ""
}
|
q56638
|
resourcesHandlerError
|
train
|
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
|
{
"resource": ""
}
|
q56639
|
resourcesHandlerLoaded
|
train
|
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
|
{
"resource": ""
}
|
q56640
|
delayLoading
|
train
|
function delayLoading (args) {
ariaCoreTimer.addCallback({
fn : resourcesHandlerLoaded,
args : args,
scope : {},
delay : 12
});
}
|
javascript
|
{
"resource": ""
}
|
q56641
|
loadResourcesHandler
|
train
|
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
|
{
"resource": ""
}
|
q56642
|
train
|
function (resourcesHandler) {
if (ariaUtilsType.isString(resourcesHandler)) {
resourcesHandler = loadResourcesHandler(resourcesHandler, this);
this._autoDisposeHandler = true;
}
this._resourcesHandler = resourcesHandler;
}
|
javascript
|
{
"resource": ""
}
|
|
q56643
|
train
|
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
|
{
"resource": ""
}
|
|
q56644
|
train
|
function(receiver, name, state) {
if (state == null) {
state = true;
}
var flagName = this._buildFlagName(name);
receiver[flagName] = state;
return state;
}
|
javascript
|
{
"resource": ""
}
|
|
q56645
|
train
|
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
|
{
"resource": ""
}
|
|
q56646
|
train
|
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
|
{
"resource": ""
}
|
|
q56647
|
train
|
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
|
{
"resource": ""
}
|
|
q56648
|
train
|
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
|
{
"resource": ""
}
|
|
q56649
|
train
|
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
|
{
"resource": ""
}
|
|
q56650
|
train
|
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
|
{
"resource": ""
}
|
|
q56651
|
train
|
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
|
{
"resource": ""
}
|
|
q56652
|
train
|
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
|
{
"resource": ""
}
|
|
q56653
|
train
|
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
|
{
"resource": ""
}
|
|
q56654
|
train
|
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
|
{
"resource": ""
}
|
|
q56655
|
train
|
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
|
{
"resource": ""
}
|
|
q56656
|
train
|
function (event, template) {
this.moduleCtrl.displayHighlight(template.templateCtxt.getContainerDiv());
this.data.overModuleCtrl = template.moduleCtrl;
this.mouseOver(event);
this._refreshModulesDisplay();
// prevent propagation
event.stopPropagation();
}
|
javascript
|
{
"resource": ""
}
|
|
q56657
|
train
|
function (event, template) {
// this.moduleCtrl.clearHighlight();
this.data.overModuleCtrl = null;
this.mouseOut(event);
this._refreshModulesDisplay();
// prevent propagation
event.stopPropagation();
}
|
javascript
|
{
"resource": ""
}
|
|
q56658
|
train
|
function (event, module) {
this.data.overTemplates = module.outerTemplateCtxts;
this.mouseOver(event);
this._refreshTemplatesDisplay();
// prevent propagation
event.stopPropagation();
}
|
javascript
|
{
"resource": ""
}
|
|
q56659
|
train
|
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
|
{
"resource": ""
}
|
|
q56660
|
train
|
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
|
{
"resource": ""
}
|
|
q56661
|
train
|
function (domElt, count) {
if (count == null) {
count = 1;
}
while (domElt && count > 0) {
domElt = domElt.nextSibling;
if (domElt && domElt.nodeType == 1) {
count--;
}
}
return domElt;
}
|
javascript
|
{
"resource": ""
}
|
|
q56662
|
train
|
function (domElt, count) {
if (count == null) {
count = 1;
}
while (domElt && count > 0) {
domElt = domElt.previousSibling;
if (domElt && domElt.nodeType == 1) {
count--;
}
}
return domElt;
}
|
javascript
|
{
"resource": ""
}
|
|
q56663
|
train
|
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
|
{
"resource": ""
}
|
|
q56664
|
train
|
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
|
{
"resource": ""
}
|
|
q56665
|
train
|
function (oldElt, newElt) {
var parentNode = oldElt.parentNode;
parentNode.insertBefore(newElt, oldElt);
parentNode.removeChild(oldElt);
}
|
javascript
|
{
"resource": ""
}
|
|
q56666
|
train
|
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
|
{
"resource": ""
}
|
|
q56667
|
train
|
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
|
{
"resource": ""
}
|
|
q56668
|
train
|
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
|
{
"resource": ""
}
|
|
q56669
|
train
|
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
|
{
"resource": ""
}
|
|
q56670
|
train
|
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
|
{
"resource": ""
}
|
|
q56671
|
train
|
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
|
{
"resource": ""
}
|
|
q56672
|
train
|
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
|
{
"resource": ""
}
|
|
q56673
|
train
|
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
|
{
"resource": ""
}
|
|
q56674
|
train
|
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
|
{
"resource": ""
}
|
|
q56675
|
train
|
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
|
{
"resource": ""
}
|
|
q56676
|
train
|
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
|
{
"resource": ""
}
|
|
q56677
|
train
|
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
|
{
"resource": ""
}
|
|
q56678
|
train
|
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
|
{
"resource": ""
}
|
|
q56679
|
train
|
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
|
{
"resource": ""
}
|
|
q56680
|
train
|
function (element, opacity) {
var browser = ariaCoreBrowser;
var isIE8OrLess = (browser.isIE8 || browser.isIE7);
this.setOpacity = isIE8OrLess ? this._setOpacityLegacyIE : this._setOpacityW3C;
this.setOpacity(element, opacity);
}
|
javascript
|
{
"resource": ""
}
|
|
q56681
|
train
|
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
|
{
"resource": ""
}
|
|
q56682
|
train
|
function (widget, msgArgs) {
if (widget._context) {
if (!msgArgs) {
msgArgs = [];
}
msgArgs.unshift("Template: " + widget._context.tplClasspath + ", Line: " + widget._lineNumber + "\n");
}
return msgArgs;
}
|
javascript
|
{
"resource": ""
}
|
|
q56683
|
train
|
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
|
{
"resource": ""
}
|
|
q56684
|
train
|
function () {
var dynamicIds = this._dynamicIds;
if (dynamicIds) {
for (var i = dynamicIds.length - 1; i >= 0; i--) {
idMgr.releaseId(dynamicIds[i]);
}
this._dynamicIds = null;
}
}
|
javascript
|
{
"resource": ""
}
|
|
q56685
|
train
|
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
|
{
"resource": ""
}
|
|
q56686
|
train
|
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
|
{
"resource": ""
}
|
|
q56687
|
train
|
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
|
{
"resource": ""
}
|
|
q56688
|
train
|
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
|
{
"resource": ""
}
|
|
q56689
|
train
|
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
|
{
"resource": ""
}
|
|
q56690
|
train
|
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
|
{
"resource": ""
}
|
|
q56691
|
train
|
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
|
{
"resource": ""
}
|
|
q56692
|
train
|
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
|
{
"resource": ""
}
|
|
q56693
|
train
|
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
|
{
"resource": ""
}
|
|
q56694
|
train
|
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
|
{
"resource": ""
}
|
|
q56695
|
train
|
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
|
{
"resource": ""
}
|
|
q56696
|
train
|
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
|
{
"resource": ""
}
|
|
q56697
|
train
|
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
|
{
"resource": ""
}
|
|
q56698
|
train
|
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
|
{
"resource": ""
}
|
|
q56699
|
train
|
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
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.