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 |
---|---|---|---|---|---|---|---|---|---|---|---|
ariatemplates/ariatemplates | src/aria/modules/RequestMgr.js | function (requestPath, params) {
if (!params || params.length === 0) {
// Nothing to do if there are no parameters
return requestPath;
}
// Flatten the array of global parameters
var flat = [];
for (var i = 0, len = params.length; i < len; i += 1) {
var par = params[i];
// The value is already encoded inside the addParam
flat.push(par.name + '=' + par.value);
}
/*
* Just in case we want to change it in the future. W3C recommends to use semi columns instead of ampersand
* http://www.w3.org/TR/1999/REC-html401-19991224/appendix/notes.html#h-B.2.2
*/
var parametersSeparator = "&";
var flatString = flat.join(parametersSeparator);
return this.__appendActionParameters(requestPath, flatString);
} | javascript | function (requestPath, params) {
if (!params || params.length === 0) {
// Nothing to do if there are no parameters
return requestPath;
}
// Flatten the array of global parameters
var flat = [];
for (var i = 0, len = params.length; i < len; i += 1) {
var par = params[i];
// The value is already encoded inside the addParam
flat.push(par.name + '=' + par.value);
}
/*
* Just in case we want to change it in the future. W3C recommends to use semi columns instead of ampersand
* http://www.w3.org/TR/1999/REC-html401-19991224/appendix/notes.html#h-B.2.2
*/
var parametersSeparator = "&";
var flatString = flat.join(parametersSeparator);
return this.__appendActionParameters(requestPath, flatString);
} | [
"function",
"(",
"requestPath",
",",
"params",
")",
"{",
"if",
"(",
"!",
"params",
"||",
"params",
".",
"length",
"===",
"0",
")",
"{",
"return",
"requestPath",
";",
"}",
"var",
"flat",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"params",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"+=",
"1",
")",
"{",
"var",
"par",
"=",
"params",
"[",
"i",
"]",
";",
"flat",
".",
"push",
"(",
"par",
".",
"name",
"+",
"'='",
"+",
"par",
".",
"value",
")",
";",
"}",
"var",
"parametersSeparator",
"=",
"\"&\"",
";",
"var",
"flatString",
"=",
"flat",
".",
"join",
"(",
"parametersSeparator",
")",
";",
"return",
"this",
".",
"__appendActionParameters",
"(",
"requestPath",
",",
"flatString",
")",
";",
"}"
]
| Append the global parameters to a url request path. Global parameters are objects with properties name and
value
@param {String} requestPath The base requestPath
@param {Array} params List of parameters (added through addParam)
@return {String} the final requestPath
@private | [
"Append",
"the",
"global",
"parameters",
"to",
"a",
"url",
"request",
"path",
".",
"Global",
"parameters",
"are",
"objects",
"with",
"properties",
"name",
"and",
"value"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/modules/RequestMgr.js#L692-L715 | train |
|
ariatemplates/ariatemplates | src/aria/modules/RequestMgr.js | function (requestPath, params) {
requestPath = requestPath || "";
if (!params) {
// Nothing to do if there are no parameters
return requestPath;
}
var idx = requestPath.indexOf('?');
/*
* Just in case we want to change it in the future. W3C recommends to use semi columns instead of ampersand
* http://www.w3.org/TR/1999/REC-html401-19991224/appendix/notes.html#h-B.2.2
*/
var parametersSeparator = "&";
if (idx > -1) {
requestPath += parametersSeparator;
} else {
requestPath += "?";
}
return requestPath + params;
} | javascript | function (requestPath, params) {
requestPath = requestPath || "";
if (!params) {
// Nothing to do if there are no parameters
return requestPath;
}
var idx = requestPath.indexOf('?');
/*
* Just in case we want to change it in the future. W3C recommends to use semi columns instead of ampersand
* http://www.w3.org/TR/1999/REC-html401-19991224/appendix/notes.html#h-B.2.2
*/
var parametersSeparator = "&";
if (idx > -1) {
requestPath += parametersSeparator;
} else {
requestPath += "?";
}
return requestPath + params;
} | [
"function",
"(",
"requestPath",
",",
"params",
")",
"{",
"requestPath",
"=",
"requestPath",
"||",
"\"\"",
";",
"if",
"(",
"!",
"params",
")",
"{",
"return",
"requestPath",
";",
"}",
"var",
"idx",
"=",
"requestPath",
".",
"indexOf",
"(",
"'?'",
")",
";",
"var",
"parametersSeparator",
"=",
"\"&\"",
";",
"if",
"(",
"idx",
">",
"-",
"1",
")",
"{",
"requestPath",
"+=",
"parametersSeparator",
";",
"}",
"else",
"{",
"requestPath",
"+=",
"\"?\"",
";",
"}",
"return",
"requestPath",
"+",
"params",
";",
"}"
]
| Append the action parameters to a url request path. Action parameters are strings
@param {String} requestPath The base requestPath
@param {String} params String with the parameters
@return {String} the final requestPath
@private | [
"Append",
"the",
"action",
"parameters",
"to",
"a",
"url",
"request",
"path",
".",
"Action",
"parameters",
"are",
"strings"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/modules/RequestMgr.js#L724-L746 | train |
|
ariatemplates/ariatemplates | src/aria/modules/RequestMgr.js | function (actionName) {
actionName = actionName || "";
var idx = actionName.indexOf("?");
var object = {
name : "",
params : ""
};
if (idx < 0) {
object.name = actionName;
} else {
object = {
name : actionName.substring(0, idx),
params : actionName.substring(idx + 1)
};
}
return object;
} | javascript | function (actionName) {
actionName = actionName || "";
var idx = actionName.indexOf("?");
var object = {
name : "",
params : ""
};
if (idx < 0) {
object.name = actionName;
} else {
object = {
name : actionName.substring(0, idx),
params : actionName.substring(idx + 1)
};
}
return object;
} | [
"function",
"(",
"actionName",
")",
"{",
"actionName",
"=",
"actionName",
"||",
"\"\"",
";",
"var",
"idx",
"=",
"actionName",
".",
"indexOf",
"(",
"\"?\"",
")",
";",
"var",
"object",
"=",
"{",
"name",
":",
"\"\"",
",",
"params",
":",
"\"\"",
"}",
";",
"if",
"(",
"idx",
"<",
"0",
")",
"{",
"object",
".",
"name",
"=",
"actionName",
";",
"}",
"else",
"{",
"object",
"=",
"{",
"name",
":",
"actionName",
".",
"substring",
"(",
"0",
",",
"idx",
")",
",",
"params",
":",
"actionName",
".",
"substring",
"(",
"idx",
"+",
"1",
")",
"}",
";",
"}",
"return",
"object",
";",
"}"
]
| Given an action name extract the request parameters after a question mark
@param {String} actionName Action name i.e. "action?par1=2"
@return {Object} properties "name" and "params"
@private | [
"Given",
"an",
"action",
"name",
"extract",
"the",
"request",
"parameters",
"after",
"a",
"question",
"mark"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/modules/RequestMgr.js#L754-L773 | train |
|
ariatemplates/ariatemplates | src/aria/modules/RequestMgr.js | function () {
if (!this._urlService) {
var cfg = ariaModulesUrlServiceEnvironmentUrlService.getUrlServiceCfg(), actionUrlPattern = cfg.args[0], i18nUrlPattern = cfg.args[1];
var ClassRef = Aria.getClassRef(cfg.implementation);
this._urlService = new (ClassRef)(actionUrlPattern, i18nUrlPattern);
}
return this._urlService;
} | javascript | function () {
if (!this._urlService) {
var cfg = ariaModulesUrlServiceEnvironmentUrlService.getUrlServiceCfg(), actionUrlPattern = cfg.args[0], i18nUrlPattern = cfg.args[1];
var ClassRef = Aria.getClassRef(cfg.implementation);
this._urlService = new (ClassRef)(actionUrlPattern, i18nUrlPattern);
}
return this._urlService;
} | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_urlService",
")",
"{",
"var",
"cfg",
"=",
"ariaModulesUrlServiceEnvironmentUrlService",
".",
"getUrlServiceCfg",
"(",
")",
",",
"actionUrlPattern",
"=",
"cfg",
".",
"args",
"[",
"0",
"]",
",",
"i18nUrlPattern",
"=",
"cfg",
".",
"args",
"[",
"1",
"]",
";",
"var",
"ClassRef",
"=",
"Aria",
".",
"getClassRef",
"(",
"cfg",
".",
"implementation",
")",
";",
"this",
".",
"_urlService",
"=",
"new",
"(",
"ClassRef",
")",
"(",
"actionUrlPattern",
",",
"i18nUrlPattern",
")",
";",
"}",
"return",
"this",
".",
"_urlService",
";",
"}"
]
| Internal function to get an instance implementation of UrlService
@private
@return {Object} the instance | [
"Internal",
"function",
"to",
"get",
"an",
"instance",
"implementation",
"of",
"UrlService"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/modules/RequestMgr.js#L780-L787 | train |
|
ariatemplates/ariatemplates | src/aria/modules/RequestMgr.js | function () {
if (!this._requestHandler) {
var cfg = ariaModulesRequestHandlerEnvironmentRequestHandler.getRequestHandlerCfg();
this._requestHandler = Aria.getClassInstance(cfg.implementation, cfg.args);
}
return this._requestHandler;
} | javascript | function () {
if (!this._requestHandler) {
var cfg = ariaModulesRequestHandlerEnvironmentRequestHandler.getRequestHandlerCfg();
this._requestHandler = Aria.getClassInstance(cfg.implementation, cfg.args);
}
return this._requestHandler;
} | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_requestHandler",
")",
"{",
"var",
"cfg",
"=",
"ariaModulesRequestHandlerEnvironmentRequestHandler",
".",
"getRequestHandlerCfg",
"(",
")",
";",
"this",
".",
"_requestHandler",
"=",
"Aria",
".",
"getClassInstance",
"(",
"cfg",
".",
"implementation",
",",
"cfg",
".",
"args",
")",
";",
"}",
"return",
"this",
".",
"_requestHandler",
";",
"}"
]
| Internal function to get an instance implementation of RequestHandler
@private
@return {Object} the instance | [
"Internal",
"function",
"to",
"get",
"an",
"instance",
"implementation",
"of",
"RequestHandler"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/modules/RequestMgr.js#L794-L800 | train |
|
ariatemplates/ariatemplates | src/aria/touch/widgets/Slider.js | function () {
var val = this._value;
if (val >= this._switchThreshold) {
this._onContainer.style.width = this._cfg.width + "px";
this._onContainer.style.left = "0px";
this._offContainer.style.width = "0px";
this._value = 1;
} else {
this._offContainer.style.width = this._cfg.width + "px";
this._offContainer.style.left = "0px";
this._onContainer.style.width = "0px";
this._value = 0;
}
if (val !== this._value) {
this._storeValue();
}
} | javascript | function () {
var val = this._value;
if (val >= this._switchThreshold) {
this._onContainer.style.width = this._cfg.width + "px";
this._onContainer.style.left = "0px";
this._offContainer.style.width = "0px";
this._value = 1;
} else {
this._offContainer.style.width = this._cfg.width + "px";
this._offContainer.style.left = "0px";
this._onContainer.style.width = "0px";
this._value = 0;
}
if (val !== this._value) {
this._storeValue();
}
} | [
"function",
"(",
")",
"{",
"var",
"val",
"=",
"this",
".",
"_value",
";",
"if",
"(",
"val",
">=",
"this",
".",
"_switchThreshold",
")",
"{",
"this",
".",
"_onContainer",
".",
"style",
".",
"width",
"=",
"this",
".",
"_cfg",
".",
"width",
"+",
"\"px\"",
";",
"this",
".",
"_onContainer",
".",
"style",
".",
"left",
"=",
"\"0px\"",
";",
"this",
".",
"_offContainer",
".",
"style",
".",
"width",
"=",
"\"0px\"",
";",
"this",
".",
"_value",
"=",
"1",
";",
"}",
"else",
"{",
"this",
".",
"_offContainer",
".",
"style",
".",
"width",
"=",
"this",
".",
"_cfg",
".",
"width",
"+",
"\"px\"",
";",
"this",
".",
"_offContainer",
".",
"style",
".",
"left",
"=",
"\"0px\"",
";",
"this",
".",
"_onContainer",
".",
"style",
".",
"width",
"=",
"\"0px\"",
";",
"this",
".",
"_value",
"=",
"0",
";",
"}",
"if",
"(",
"val",
"!==",
"this",
".",
"_value",
")",
"{",
"this",
".",
"_storeValue",
"(",
")",
";",
"}",
"}"
]
| Update the position of the on and off labels
@protected | [
"Update",
"the",
"position",
"of",
"the",
"on",
"and",
"off",
"labels"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/touch/widgets/Slider.js#L336-L352 | train |
|
ariatemplates/ariatemplates | src/aria/touch/widgets/Slider.js | function () {
var binding = this._binding;
if (binding) {
ariaUtilsJson.setValue(binding.inside, binding.to, this._value, this._bindingCallback);
}
} | javascript | function () {
var binding = this._binding;
if (binding) {
ariaUtilsJson.setValue(binding.inside, binding.to, this._value, this._bindingCallback);
}
} | [
"function",
"(",
")",
"{",
"var",
"binding",
"=",
"this",
".",
"_binding",
";",
"if",
"(",
"binding",
")",
"{",
"ariaUtilsJson",
".",
"setValue",
"(",
"binding",
".",
"inside",
",",
"binding",
".",
"to",
",",
"this",
".",
"_value",
",",
"this",
".",
"_bindingCallback",
")",
";",
"}",
"}"
]
| Store the current widget value in the bound location
@param {Integer} value Value of the slider
@protected | [
"Store",
"the",
"current",
"widget",
"value",
"in",
"the",
"bound",
"location"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/touch/widgets/Slider.js#L431-L436 | train |
|
ariatemplates/ariatemplates | src/aria/touch/widgets/Slider.js | function () {
var dragVal = this._slider.offsetLeft;
this._onContainer.style.width = (this._sliderWidth + dragVal) + "px";
this._offContainer.style.left = dragVal + "px";
this._offContainer.style.width = (this._cfg.width - dragVal) + "px";
} | javascript | function () {
var dragVal = this._slider.offsetLeft;
this._onContainer.style.width = (this._sliderWidth + dragVal) + "px";
this._offContainer.style.left = dragVal + "px";
this._offContainer.style.width = (this._cfg.width - dragVal) + "px";
} | [
"function",
"(",
")",
"{",
"var",
"dragVal",
"=",
"this",
".",
"_slider",
".",
"offsetLeft",
";",
"this",
".",
"_onContainer",
".",
"style",
".",
"width",
"=",
"(",
"this",
".",
"_sliderWidth",
"+",
"dragVal",
")",
"+",
"\"px\"",
";",
"this",
".",
"_offContainer",
".",
"style",
".",
"left",
"=",
"dragVal",
"+",
"\"px\"",
";",
"this",
".",
"_offContainer",
".",
"style",
".",
"width",
"=",
"(",
"this",
".",
"_cfg",
".",
"width",
"-",
"dragVal",
")",
"+",
"\"px\"",
";",
"}"
]
| Move the On and Off state elements
@protected | [
"Move",
"the",
"On",
"and",
"Off",
"state",
"elements"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/touch/widgets/Slider.js#L457-L462 | train |
|
ariatemplates/ariatemplates | src/aria/touch/widgets/Slider.js | function () {
var pos = this._savedX, newValue = Math.max(pos / this._railWidth, 0);
if (newValue !== this._value) {
this._value = newValue;
this._storeValue();
} else {
this._notifyDataChange();
}
return;
} | javascript | function () {
var pos = this._savedX, newValue = Math.max(pos / this._railWidth, 0);
if (newValue !== this._value) {
this._value = newValue;
this._storeValue();
} else {
this._notifyDataChange();
}
return;
} | [
"function",
"(",
")",
"{",
"var",
"pos",
"=",
"this",
".",
"_savedX",
",",
"newValue",
"=",
"Math",
".",
"max",
"(",
"pos",
"/",
"this",
".",
"_railWidth",
",",
"0",
")",
";",
"if",
"(",
"newValue",
"!==",
"this",
".",
"_value",
")",
"{",
"this",
".",
"_value",
"=",
"newValue",
";",
"this",
".",
"_storeValue",
"(",
")",
";",
"}",
"else",
"{",
"this",
".",
"_notifyDataChange",
"(",
")",
";",
"}",
"return",
";",
"}"
]
| Set the value of the slider in the data model.
@param {Number} newValue new value
@protected | [
"Set",
"the",
"value",
"of",
"the",
"slider",
"in",
"the",
"data",
"model",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/touch/widgets/Slider.js#L469-L478 | train |
|
ariatemplates/ariatemplates | src/aria/touch/widgets/Slider.js | function (applySwitchMargins) {
var value;
var binding = this._binding;
if (!binding) {
return;
}
value = binding.inside[binding.to];
if (value == null) {
value = 0;
}
if (value < 0) {
value = 0;
}
if (value > 1) {
value = 1;
}
if (this._isSwitch && applySwitchMargins) {
if (value >= this._switchThreshold) {
value = 1;
} else {
value = 0;
}
}
this._value = value;
this._storeValue();
} | javascript | function (applySwitchMargins) {
var value;
var binding = this._binding;
if (!binding) {
return;
}
value = binding.inside[binding.to];
if (value == null) {
value = 0;
}
if (value < 0) {
value = 0;
}
if (value > 1) {
value = 1;
}
if (this._isSwitch && applySwitchMargins) {
if (value >= this._switchThreshold) {
value = 1;
} else {
value = 0;
}
}
this._value = value;
this._storeValue();
} | [
"function",
"(",
"applySwitchMargins",
")",
"{",
"var",
"value",
";",
"var",
"binding",
"=",
"this",
".",
"_binding",
";",
"if",
"(",
"!",
"binding",
")",
"{",
"return",
";",
"}",
"value",
"=",
"binding",
".",
"inside",
"[",
"binding",
".",
"to",
"]",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"value",
"=",
"0",
";",
"}",
"if",
"(",
"value",
"<",
"0",
")",
"{",
"value",
"=",
"0",
";",
"}",
"if",
"(",
"value",
">",
"1",
")",
"{",
"value",
"=",
"1",
";",
"}",
"if",
"(",
"this",
".",
"_isSwitch",
"&&",
"applySwitchMargins",
")",
"{",
"if",
"(",
"value",
">=",
"this",
".",
"_switchThreshold",
")",
"{",
"value",
"=",
"1",
";",
"}",
"else",
"{",
"value",
"=",
"0",
";",
"}",
"}",
"this",
".",
"_value",
"=",
"value",
";",
"this",
".",
"_storeValue",
"(",
")",
";",
"}"
]
| Read the bound value in the data model, ensure it is defined, between 0 and 1, and assign the _value
property.
@param {Boolean} applySwitchMargins Whether or not the value should be set to either 0 or 1 when the widget
is used as a switch
@protected | [
"Read",
"the",
"bound",
"value",
"in",
"the",
"data",
"model",
"ensure",
"it",
"is",
"defined",
"between",
"0",
"and",
"1",
"and",
"assign",
"the",
"_value",
"property",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/touch/widgets/Slider.js#L487-L513 | train |
|
ariatemplates/ariatemplates | src/aria/touch/widgets/Slider.js | function (evt) {
if (evt.type === "tap") {
var cfg = this._cfg;
if (!cfg) {
// Widget already disposed
return true;
}
if ((cfg.tapToToggle || cfg.tapToMove) && this._isSwitch) {
// With this configuration, on tap we want to toggle the value
this._value = this._value >= this._switchThreshold ? 0 : 1;
} else if (cfg.tapToMove) {
this._savedX = evt.detail.currentX - this._sliderDimension.x - this._sliderWidth / 2;
this._savedX = (this._savedX > this._railWidth) ? this._railWidth : this._savedX;
this._value = Math.max(this._savedX / this._railWidth, 0);
}
this._storeValue();
this._setLeftPosition();
this._updateDisplay();
}
} | javascript | function (evt) {
if (evt.type === "tap") {
var cfg = this._cfg;
if (!cfg) {
// Widget already disposed
return true;
}
if ((cfg.tapToToggle || cfg.tapToMove) && this._isSwitch) {
// With this configuration, on tap we want to toggle the value
this._value = this._value >= this._switchThreshold ? 0 : 1;
} else if (cfg.tapToMove) {
this._savedX = evt.detail.currentX - this._sliderDimension.x - this._sliderWidth / 2;
this._savedX = (this._savedX > this._railWidth) ? this._railWidth : this._savedX;
this._value = Math.max(this._savedX / this._railWidth, 0);
}
this._storeValue();
this._setLeftPosition();
this._updateDisplay();
}
} | [
"function",
"(",
"evt",
")",
"{",
"if",
"(",
"evt",
".",
"type",
"===",
"\"tap\"",
")",
"{",
"var",
"cfg",
"=",
"this",
".",
"_cfg",
";",
"if",
"(",
"!",
"cfg",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"(",
"cfg",
".",
"tapToToggle",
"||",
"cfg",
".",
"tapToMove",
")",
"&&",
"this",
".",
"_isSwitch",
")",
"{",
"this",
".",
"_value",
"=",
"this",
".",
"_value",
">=",
"this",
".",
"_switchThreshold",
"?",
"0",
":",
"1",
";",
"}",
"else",
"if",
"(",
"cfg",
".",
"tapToMove",
")",
"{",
"this",
".",
"_savedX",
"=",
"evt",
".",
"detail",
".",
"currentX",
"-",
"this",
".",
"_sliderDimension",
".",
"x",
"-",
"this",
".",
"_sliderWidth",
"/",
"2",
";",
"this",
".",
"_savedX",
"=",
"(",
"this",
".",
"_savedX",
">",
"this",
".",
"_railWidth",
")",
"?",
"this",
".",
"_railWidth",
":",
"this",
".",
"_savedX",
";",
"this",
".",
"_value",
"=",
"Math",
".",
"max",
"(",
"this",
".",
"_savedX",
"/",
"this",
".",
"_railWidth",
",",
"0",
")",
";",
"}",
"this",
".",
"_storeValue",
"(",
")",
";",
"this",
".",
"_setLeftPosition",
"(",
")",
";",
"this",
".",
"_updateDisplay",
"(",
")",
";",
"}",
"}"
]
| Handle delegated events
@param {HTMLEvent} evt Browser event | [
"Handle",
"delegated",
"events"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/touch/widgets/Slider.js#L555-L575 | train |
|
ariatemplates/ariatemplates | src/aria/embed/controllers/MapController.js | function (container, cfg) {
var localMapStatus = this.mapManager.getMapStatus(cfg.id);
var mapDom = mapDoms[cfg.id];
if (localMapStatus === null) {
this._createMap(container, cfg);
} else {
container.appendChild(mapDom);
}
localMapStatus = this.mapManager.getMapStatus(cfg.id);
if (cfg.loadingIndicator && localMapStatus != this.mapManager.READY) {
this._activateLoadingIndicator(container, cfg);
}
} | javascript | function (container, cfg) {
var localMapStatus = this.mapManager.getMapStatus(cfg.id);
var mapDom = mapDoms[cfg.id];
if (localMapStatus === null) {
this._createMap(container, cfg);
} else {
container.appendChild(mapDom);
}
localMapStatus = this.mapManager.getMapStatus(cfg.id);
if (cfg.loadingIndicator && localMapStatus != this.mapManager.READY) {
this._activateLoadingIndicator(container, cfg);
}
} | [
"function",
"(",
"container",
",",
"cfg",
")",
"{",
"var",
"localMapStatus",
"=",
"this",
".",
"mapManager",
".",
"getMapStatus",
"(",
"cfg",
".",
"id",
")",
";",
"var",
"mapDom",
"=",
"mapDoms",
"[",
"cfg",
".",
"id",
"]",
";",
"if",
"(",
"localMapStatus",
"===",
"null",
")",
"{",
"this",
".",
"_createMap",
"(",
"container",
",",
"cfg",
")",
";",
"}",
"else",
"{",
"container",
".",
"appendChild",
"(",
"mapDom",
")",
";",
"}",
"localMapStatus",
"=",
"this",
".",
"mapManager",
".",
"getMapStatus",
"(",
"cfg",
".",
"id",
")",
";",
"if",
"(",
"cfg",
".",
"loadingIndicator",
"&&",
"localMapStatus",
"!=",
"this",
".",
"mapManager",
".",
"READY",
")",
"{",
"this",
".",
"_activateLoadingIndicator",
"(",
"container",
",",
"cfg",
")",
";",
"}",
"}"
]
| Called by the Map embed widget at initialization
@param {HTMLElement} container
@param {Object} cfg | [
"Called",
"by",
"the",
"Map",
"embed",
"widget",
"at",
"initialization"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/embed/controllers/MapController.js#L75-L87 | train |
|
ariatemplates/ariatemplates | src/aria/embed/controllers/MapController.js | function (evt) {
var args = mapReadyHandlerArgs[evt.mapId];
if (args) {
this._triggerLoadingIndicator(args.container, false);
delete mapReadyHandlerArgs[evt.mapId];
this._listeners--;
if (this._listeners === 0) {
this.mapManager.$removeListeners({
"mapReady" : {
fn : this._removeLoadingIndicator,
scope : this
}
});
}
}
} | javascript | function (evt) {
var args = mapReadyHandlerArgs[evt.mapId];
if (args) {
this._triggerLoadingIndicator(args.container, false);
delete mapReadyHandlerArgs[evt.mapId];
this._listeners--;
if (this._listeners === 0) {
this.mapManager.$removeListeners({
"mapReady" : {
fn : this._removeLoadingIndicator,
scope : this
}
});
}
}
} | [
"function",
"(",
"evt",
")",
"{",
"var",
"args",
"=",
"mapReadyHandlerArgs",
"[",
"evt",
".",
"mapId",
"]",
";",
"if",
"(",
"args",
")",
"{",
"this",
".",
"_triggerLoadingIndicator",
"(",
"args",
".",
"container",
",",
"false",
")",
";",
"delete",
"mapReadyHandlerArgs",
"[",
"evt",
".",
"mapId",
"]",
";",
"this",
".",
"_listeners",
"--",
";",
"if",
"(",
"this",
".",
"_listeners",
"===",
"0",
")",
"{",
"this",
".",
"mapManager",
".",
"$removeListeners",
"(",
"{",
"\"mapReady\"",
":",
"{",
"fn",
":",
"this",
".",
"_removeLoadingIndicator",
",",
"scope",
":",
"this",
"}",
"}",
")",
";",
"}",
"}",
"}"
]
| "mapReady" event handler. Used in case the map is loading
@param {Object} evt Event description
@private | [
"mapReady",
"event",
"handler",
".",
"Used",
"in",
"case",
"the",
"map",
"is",
"loading"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/embed/controllers/MapController.js#L132-L148 | train |
|
ariatemplates/ariatemplates | src/aria/embed/controllers/MapController.js | function (container, cfg) {
var id = cfg.id;
if (cfg.loadingIndicator) {
this._triggerLoadingIndicator(container, false);
}
var mapDom = mapDoms[id];
if (mapDom) {
var parent = mapDom.parentNode;
if (parent) {
parent.removeChild(mapDom);
}
}
} | javascript | function (container, cfg) {
var id = cfg.id;
if (cfg.loadingIndicator) {
this._triggerLoadingIndicator(container, false);
}
var mapDom = mapDoms[id];
if (mapDom) {
var parent = mapDom.parentNode;
if (parent) {
parent.removeChild(mapDom);
}
}
} | [
"function",
"(",
"container",
",",
"cfg",
")",
"{",
"var",
"id",
"=",
"cfg",
".",
"id",
";",
"if",
"(",
"cfg",
".",
"loadingIndicator",
")",
"{",
"this",
".",
"_triggerLoadingIndicator",
"(",
"container",
",",
"false",
")",
";",
"}",
"var",
"mapDom",
"=",
"mapDoms",
"[",
"id",
"]",
";",
"if",
"(",
"mapDom",
")",
"{",
"var",
"parent",
"=",
"mapDom",
".",
"parentNode",
";",
"if",
"(",
"parent",
")",
"{",
"parent",
".",
"removeChild",
"(",
"mapDom",
")",
";",
"}",
"}",
"}"
]
| Called by the Map embed widget at disposal
@param {HTMLElement} container
@param {Object} cfg | [
"Called",
"by",
"the",
"Map",
"embed",
"widget",
"at",
"disposal"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/embed/controllers/MapController.js#L155-L167 | train |
|
ariatemplates/ariatemplates | src/aria/utils/Mouse.js | connectMouseEvents | function connectMouseEvents (scope) {
var root = (aria.core.Browser.isIE7 || aria.core.Browser.isIE8) ? Aria.$window.document.body : Aria.$window;
eventUtil.addListener(root, "mousemove", {
fn : scope._onMouseMove,
scope : scope
});
eventUtil.addListener(root, "mouseup", {
fn : scope._onMouseUp,
scope : scope
});
eventUtil.addListener(root, "touchmove", {
fn : scope._onMouseMove,
scope : scope
});
eventUtil.addListener(root, "touchend", {
fn : scope._onMouseUp,
scope : scope
});
} | javascript | function connectMouseEvents (scope) {
var root = (aria.core.Browser.isIE7 || aria.core.Browser.isIE8) ? Aria.$window.document.body : Aria.$window;
eventUtil.addListener(root, "mousemove", {
fn : scope._onMouseMove,
scope : scope
});
eventUtil.addListener(root, "mouseup", {
fn : scope._onMouseUp,
scope : scope
});
eventUtil.addListener(root, "touchmove", {
fn : scope._onMouseMove,
scope : scope
});
eventUtil.addListener(root, "touchend", {
fn : scope._onMouseUp,
scope : scope
});
} | [
"function",
"connectMouseEvents",
"(",
"scope",
")",
"{",
"var",
"root",
"=",
"(",
"aria",
".",
"core",
".",
"Browser",
".",
"isIE7",
"||",
"aria",
".",
"core",
".",
"Browser",
".",
"isIE8",
")",
"?",
"Aria",
".",
"$window",
".",
"document",
".",
"body",
":",
"Aria",
".",
"$window",
";",
"eventUtil",
".",
"addListener",
"(",
"root",
",",
"\"mousemove\"",
",",
"{",
"fn",
":",
"scope",
".",
"_onMouseMove",
",",
"scope",
":",
"scope",
"}",
")",
";",
"eventUtil",
".",
"addListener",
"(",
"root",
",",
"\"mouseup\"",
",",
"{",
"fn",
":",
"scope",
".",
"_onMouseUp",
",",
"scope",
":",
"scope",
"}",
")",
";",
"eventUtil",
".",
"addListener",
"(",
"root",
",",
"\"touchmove\"",
",",
"{",
"fn",
":",
"scope",
".",
"_onMouseMove",
",",
"scope",
":",
"scope",
"}",
")",
";",
"eventUtil",
".",
"addListener",
"(",
"root",
",",
"\"touchend\"",
",",
"{",
"fn",
":",
"scope",
".",
"_onMouseUp",
",",
"scope",
":",
"scope",
"}",
")",
";",
"}"
]
| Connect delegated mousemove and mouseup events. For performances these are attached only after a mousedown.
@param {aria.utils.Mouse} scope Instance of the listening class | [
"Connect",
"delegated",
"mousemove",
"and",
"mouseup",
"events",
".",
"For",
"performances",
"these",
"are",
"attached",
"only",
"after",
"a",
"mousedown",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Mouse.js#L39-L57 | train |
ariatemplates/ariatemplates | src/aria/utils/Mouse.js | disconnectMouseEvents | function disconnectMouseEvents (scope) {
var root = (aria.core.Browser.isIE7 || aria.core.Browser.isIE8) ? Aria.$window.document.body : Aria.$window;
eventUtil.removeListener(root, "mousemove", {
fn : scope._onMouseMove,
scope : scope
});
eventUtil.removeListener(root, "mouseup", {
fn : scope._onMouseUp,
scope : scope
});
eventUtil.removeListener(root, "touchmove", {
fn : scope._onMouseMove,
scope : scope
});
eventUtil.removeListener(root, "touchend", {
fn : scope._onMouseUp,
scope : scope
});
} | javascript | function disconnectMouseEvents (scope) {
var root = (aria.core.Browser.isIE7 || aria.core.Browser.isIE8) ? Aria.$window.document.body : Aria.$window;
eventUtil.removeListener(root, "mousemove", {
fn : scope._onMouseMove,
scope : scope
});
eventUtil.removeListener(root, "mouseup", {
fn : scope._onMouseUp,
scope : scope
});
eventUtil.removeListener(root, "touchmove", {
fn : scope._onMouseMove,
scope : scope
});
eventUtil.removeListener(root, "touchend", {
fn : scope._onMouseUp,
scope : scope
});
} | [
"function",
"disconnectMouseEvents",
"(",
"scope",
")",
"{",
"var",
"root",
"=",
"(",
"aria",
".",
"core",
".",
"Browser",
".",
"isIE7",
"||",
"aria",
".",
"core",
".",
"Browser",
".",
"isIE8",
")",
"?",
"Aria",
".",
"$window",
".",
"document",
".",
"body",
":",
"Aria",
".",
"$window",
";",
"eventUtil",
".",
"removeListener",
"(",
"root",
",",
"\"mousemove\"",
",",
"{",
"fn",
":",
"scope",
".",
"_onMouseMove",
",",
"scope",
":",
"scope",
"}",
")",
";",
"eventUtil",
".",
"removeListener",
"(",
"root",
",",
"\"mouseup\"",
",",
"{",
"fn",
":",
"scope",
".",
"_onMouseUp",
",",
"scope",
":",
"scope",
"}",
")",
";",
"eventUtil",
".",
"removeListener",
"(",
"root",
",",
"\"touchmove\"",
",",
"{",
"fn",
":",
"scope",
".",
"_onMouseMove",
",",
"scope",
":",
"scope",
"}",
")",
";",
"eventUtil",
".",
"removeListener",
"(",
"root",
",",
"\"touchend\"",
",",
"{",
"fn",
":",
"scope",
".",
"_onMouseUp",
",",
"scope",
":",
"scope",
"}",
")",
";",
"}"
]
| Disconnect delegated mousemove and mouseup events.
@param {aria.utils.Mouse} scope Instance of the listening class | [
"Disconnect",
"delegated",
"mousemove",
"and",
"mouseup",
"events",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Mouse.js#L63-L81 | train |
ariatemplates/ariatemplates | src/aria/utils/Mouse.js | findByAttribute | function findByAttribute (start, attribute, maxDepth, stopper) {
var target = start, expandoValue;
while (maxDepth && target && target != stopper) {
if (target.attributes) {
var expandoValue = target.attributes[attribute];
if (expandoValue) {
return expandoValue.nodeValue;
}
}
target = target.parentNode;
maxDepth--;
}
} | javascript | function findByAttribute (start, attribute, maxDepth, stopper) {
var target = start, expandoValue;
while (maxDepth && target && target != stopper) {
if (target.attributes) {
var expandoValue = target.attributes[attribute];
if (expandoValue) {
return expandoValue.nodeValue;
}
}
target = target.parentNode;
maxDepth--;
}
} | [
"function",
"findByAttribute",
"(",
"start",
",",
"attribute",
",",
"maxDepth",
",",
"stopper",
")",
"{",
"var",
"target",
"=",
"start",
",",
"expandoValue",
";",
"while",
"(",
"maxDepth",
"&&",
"target",
"&&",
"target",
"!=",
"stopper",
")",
"{",
"if",
"(",
"target",
".",
"attributes",
")",
"{",
"var",
"expandoValue",
"=",
"target",
".",
"attributes",
"[",
"attribute",
"]",
";",
"if",
"(",
"expandoValue",
")",
"{",
"return",
"expandoValue",
".",
"nodeValue",
";",
"}",
"}",
"target",
"=",
"target",
".",
"parentNode",
";",
"maxDepth",
"--",
";",
"}",
"}"
]
| Find the first parent of 'start' element with the attribute specified by 'attribute'
@param {HTMLElement} start Node element from which we start searching
@param {String} attribute Attribute name
@param {Number} maxDepth Maximum number of elements to traverse, -1 for infinite
@param {HTMLElement} stopper Stop the search when reaching this element
@return {String} attribute value | [
"Find",
"the",
"first",
"parent",
"of",
"start",
"element",
"with",
"the",
"attribute",
"specified",
"by",
"attribute"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Mouse.js#L91-L104 | train |
ariatemplates/ariatemplates | src/aria/utils/Mouse.js | function () {
eventUtil.addListener(Aria.$window.document.body, "mousedown", {
fn : this._onMouseDown,
scope : this
});
eventUtil.addListener(Aria.$window.document.body, "touchstart", {
fn : this._onMouseDown,
scope : this
});
} | javascript | function () {
eventUtil.addListener(Aria.$window.document.body, "mousedown", {
fn : this._onMouseDown,
scope : this
});
eventUtil.addListener(Aria.$window.document.body, "touchstart", {
fn : this._onMouseDown,
scope : this
});
} | [
"function",
"(",
")",
"{",
"eventUtil",
".",
"addListener",
"(",
"Aria",
".",
"$window",
".",
"document",
".",
"body",
",",
"\"mousedown\"",
",",
"{",
"fn",
":",
"this",
".",
"_onMouseDown",
",",
"scope",
":",
"this",
"}",
")",
";",
"eventUtil",
".",
"addListener",
"(",
"Aria",
".",
"$window",
".",
"document",
".",
"body",
",",
"\"touchstart\"",
",",
"{",
"fn",
":",
"this",
".",
"_onMouseDown",
",",
"scope",
":",
"this",
"}",
")",
";",
"}"
]
| This method is called when AriaWindow sends an attachWindow event. It registers a listener on the
mousedown event. | [
"This",
"method",
"is",
"called",
"when",
"AriaWindow",
"sends",
"an",
"attachWindow",
"event",
".",
"It",
"registers",
"a",
"listener",
"on",
"the",
"mousedown",
"event",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Mouse.js#L159-L168 | train |
|
ariatemplates/ariatemplates | src/aria/utils/Mouse.js | function () {
eventUtil.removeListener(Aria.$window.document.body, "mousedown", {
fn : this._onMouseDown,
scope : this
});
eventUtil.removeListener(Aria.$window.document.body, "touchstart", {
fn : this._onMouseDown,
scope : this
});
disconnectMouseEvents(this);
} | javascript | function () {
eventUtil.removeListener(Aria.$window.document.body, "mousedown", {
fn : this._onMouseDown,
scope : this
});
eventUtil.removeListener(Aria.$window.document.body, "touchstart", {
fn : this._onMouseDown,
scope : this
});
disconnectMouseEvents(this);
} | [
"function",
"(",
")",
"{",
"eventUtil",
".",
"removeListener",
"(",
"Aria",
".",
"$window",
".",
"document",
".",
"body",
",",
"\"mousedown\"",
",",
"{",
"fn",
":",
"this",
".",
"_onMouseDown",
",",
"scope",
":",
"this",
"}",
")",
";",
"eventUtil",
".",
"removeListener",
"(",
"Aria",
".",
"$window",
".",
"document",
".",
"body",
",",
"\"touchstart\"",
",",
"{",
"fn",
":",
"this",
".",
"_onMouseDown",
",",
"scope",
":",
"this",
"}",
")",
";",
"disconnectMouseEvents",
"(",
"this",
")",
";",
"}"
]
| This method is called when AriaWindow sends a detachWindow event. It unregisters the listener on the
mousedown event. | [
"This",
"method",
"is",
"called",
"when",
"AriaWindow",
"sends",
"a",
"detachWindow",
"event",
".",
"It",
"unregisters",
"the",
"listener",
"on",
"the",
"mousedown",
"event",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Mouse.js#L174-L184 | train |
|
ariatemplates/ariatemplates | src/aria/utils/Mouse.js | function (gesture, id) {
if (this._idList[gesture]) {
var element = this._idList[gesture][id];
if (gesture == "drag" && element && element == this._activeDrag) {
// the element being dragged has been disposed,
// terminate the drag:
this._dragStartPosition = null;
disconnectMouseEvents(this);
this._candidateForDrag = null;
this._activeDrag = null;
}
delete this._idList[gesture][id];
}
} | javascript | function (gesture, id) {
if (this._idList[gesture]) {
var element = this._idList[gesture][id];
if (gesture == "drag" && element && element == this._activeDrag) {
// the element being dragged has been disposed,
// terminate the drag:
this._dragStartPosition = null;
disconnectMouseEvents(this);
this._candidateForDrag = null;
this._activeDrag = null;
}
delete this._idList[gesture][id];
}
} | [
"function",
"(",
"gesture",
",",
"id",
")",
"{",
"if",
"(",
"this",
".",
"_idList",
"[",
"gesture",
"]",
")",
"{",
"var",
"element",
"=",
"this",
".",
"_idList",
"[",
"gesture",
"]",
"[",
"id",
"]",
";",
"if",
"(",
"gesture",
"==",
"\"drag\"",
"&&",
"element",
"&&",
"element",
"==",
"this",
".",
"_activeDrag",
")",
"{",
"this",
".",
"_dragStartPosition",
"=",
"null",
";",
"disconnectMouseEvents",
"(",
"this",
")",
";",
"this",
".",
"_candidateForDrag",
"=",
"null",
";",
"this",
".",
"_activeDrag",
"=",
"null",
";",
"}",
"delete",
"this",
".",
"_idList",
"[",
"gesture",
"]",
"[",
"id",
"]",
";",
"}",
"}"
]
| Remove a listener for a mouse action or gesture.
@param {String} gesture mouse action or gesture
@param {String} id id of the listening instance | [
"Remove",
"a",
"listener",
"for",
"a",
"mouse",
"action",
"or",
"gesture",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Mouse.js#L257-L270 | train |
|
ariatemplates/ariatemplates | src/aria/utils/Mouse.js | function (evt) {
var event = new ariaDomEvent(evt);
connectMouseEvents(this);
if (evt.type === "touchstart") {
// The position of touch events is not determined correctly by clientX/Y
var elementPosition = ariaTouchEvent.getPositions(event);
event.clientX = elementPosition[0].x;
event.clientY = elementPosition[0].y;
}
if (this._detectDrag(event)) {
event.preventDefault(true);
}
event.$dispose();
return false;
} | javascript | function (evt) {
var event = new ariaDomEvent(evt);
connectMouseEvents(this);
if (evt.type === "touchstart") {
// The position of touch events is not determined correctly by clientX/Y
var elementPosition = ariaTouchEvent.getPositions(event);
event.clientX = elementPosition[0].x;
event.clientY = elementPosition[0].y;
}
if (this._detectDrag(event)) {
event.preventDefault(true);
}
event.$dispose();
return false;
} | [
"function",
"(",
"evt",
")",
"{",
"var",
"event",
"=",
"new",
"ariaDomEvent",
"(",
"evt",
")",
";",
"connectMouseEvents",
"(",
"this",
")",
";",
"if",
"(",
"evt",
".",
"type",
"===",
"\"touchstart\"",
")",
"{",
"var",
"elementPosition",
"=",
"ariaTouchEvent",
".",
"getPositions",
"(",
"event",
")",
";",
"event",
".",
"clientX",
"=",
"elementPosition",
"[",
"0",
"]",
".",
"x",
";",
"event",
".",
"clientY",
"=",
"elementPosition",
"[",
"0",
"]",
".",
"y",
";",
"}",
"if",
"(",
"this",
".",
"_detectDrag",
"(",
"event",
")",
")",
"{",
"event",
".",
"preventDefault",
"(",
"true",
")",
";",
"}",
"event",
".",
"$dispose",
"(",
")",
";",
"return",
"false",
";",
"}"
]
| Listener for the mouse down event. It detects possible gestures
@param {HTMLEvent} evt mousedown event. It is not wrapped yet
@private | [
"Listener",
"for",
"the",
"mouse",
"down",
"event",
".",
"It",
"detects",
"possible",
"gestures"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Mouse.js#L277-L295 | train |
|
ariatemplates/ariatemplates | src/aria/utils/Mouse.js | function (evt) {
var stopper = Aria.$window.document.body;
var elementId = findByAttribute(evt.target, this.DRAGGABLE_ATTRIBUTE, this.maxDepth, stopper);
if (!elementId) {
return;
}
var candidate = this._idList.drag[elementId];
this.$assert(211, !!candidate);
this._candidateForDrag = candidate;
this._dragStartPosition = {
x : evt.clientX,
y : evt.clientY
};
this._dragStarted = false;
return true;
} | javascript | function (evt) {
var stopper = Aria.$window.document.body;
var elementId = findByAttribute(evt.target, this.DRAGGABLE_ATTRIBUTE, this.maxDepth, stopper);
if (!elementId) {
return;
}
var candidate = this._idList.drag[elementId];
this.$assert(211, !!candidate);
this._candidateForDrag = candidate;
this._dragStartPosition = {
x : evt.clientX,
y : evt.clientY
};
this._dragStarted = false;
return true;
} | [
"function",
"(",
"evt",
")",
"{",
"var",
"stopper",
"=",
"Aria",
".",
"$window",
".",
"document",
".",
"body",
";",
"var",
"elementId",
"=",
"findByAttribute",
"(",
"evt",
".",
"target",
",",
"this",
".",
"DRAGGABLE_ATTRIBUTE",
",",
"this",
".",
"maxDepth",
",",
"stopper",
")",
";",
"if",
"(",
"!",
"elementId",
")",
"{",
"return",
";",
"}",
"var",
"candidate",
"=",
"this",
".",
"_idList",
".",
"drag",
"[",
"elementId",
"]",
";",
"this",
".",
"$assert",
"(",
"211",
",",
"!",
"!",
"candidate",
")",
";",
"this",
".",
"_candidateForDrag",
"=",
"candidate",
";",
"this",
".",
"_dragStartPosition",
"=",
"{",
"x",
":",
"evt",
".",
"clientX",
",",
"y",
":",
"evt",
".",
"clientY",
"}",
";",
"this",
".",
"_dragStarted",
"=",
"false",
";",
"return",
"true",
";",
"}"
]
| Base function to detect if a drag gesture is happening or not.
@param {aria.DomEvent} evt mouse down event
@private | [
"Base",
"function",
"to",
"detect",
"if",
"a",
"drag",
"gesture",
"is",
"happening",
"or",
"not",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Mouse.js#L302-L320 | train |
|
ariatemplates/ariatemplates | src/aria/utils/Mouse.js | function (coordinates) {
var element = this._candidateForDrag;
if (!element) {
return;
}
this._activeDrag = element;
this._dragStarted = true;
element.start(coordinates);
} | javascript | function (coordinates) {
var element = this._candidateForDrag;
if (!element) {
return;
}
this._activeDrag = element;
this._dragStarted = true;
element.start(coordinates);
} | [
"function",
"(",
"coordinates",
")",
"{",
"var",
"element",
"=",
"this",
".",
"_candidateForDrag",
";",
"if",
"(",
"!",
"element",
")",
"{",
"return",
";",
"}",
"this",
".",
"_activeDrag",
"=",
"element",
";",
"this",
".",
"_dragStarted",
"=",
"true",
";",
"element",
".",
"start",
"(",
"coordinates",
")",
";",
"}"
]
| After an activation delay, if no mouseup event is raised the drag has started.
@param {Object} coordinates X and Y coordinates of the initial mouse position
@private | [
"After",
"an",
"activation",
"delay",
"if",
"no",
"mouseup",
"event",
"is",
"raised",
"the",
"drag",
"has",
"started",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Mouse.js#L327-L336 | train |
|
ariatemplates/ariatemplates | src/aria/utils/Mouse.js | function (evt) {
var event = new ariaDomEvent(evt);
if (event.type === "touchmove") {
var elementPosition = ariaTouchEvent.getPositions(evt);
if (elementPosition.length === 1) {
event.clientX = elementPosition[0].x;
event.clientY = elementPosition[0].y;
}
}
if (this._dragStartPosition && !this._dragStarted) {
this._startDrag(this._dragStartPosition);
}
var element = this._activeDrag;
if (element) {
// IE mouseup check - mouseup happened when mouse was out of window
if (evt.type !== "touchmove" && !evt.button) {
var browser = ariaCoreBrowser;
if (browser.isIE8 || browser.isIE7) {
event.$dispose();
return this._onMouseUp(evt);
}
}
element.move(event);
}
event.$dispose();
} | javascript | function (evt) {
var event = new ariaDomEvent(evt);
if (event.type === "touchmove") {
var elementPosition = ariaTouchEvent.getPositions(evt);
if (elementPosition.length === 1) {
event.clientX = elementPosition[0].x;
event.clientY = elementPosition[0].y;
}
}
if (this._dragStartPosition && !this._dragStarted) {
this._startDrag(this._dragStartPosition);
}
var element = this._activeDrag;
if (element) {
// IE mouseup check - mouseup happened when mouse was out of window
if (evt.type !== "touchmove" && !evt.button) {
var browser = ariaCoreBrowser;
if (browser.isIE8 || browser.isIE7) {
event.$dispose();
return this._onMouseUp(evt);
}
}
element.move(event);
}
event.$dispose();
} | [
"function",
"(",
"evt",
")",
"{",
"var",
"event",
"=",
"new",
"ariaDomEvent",
"(",
"evt",
")",
";",
"if",
"(",
"event",
".",
"type",
"===",
"\"touchmove\"",
")",
"{",
"var",
"elementPosition",
"=",
"ariaTouchEvent",
".",
"getPositions",
"(",
"evt",
")",
";",
"if",
"(",
"elementPosition",
".",
"length",
"===",
"1",
")",
"{",
"event",
".",
"clientX",
"=",
"elementPosition",
"[",
"0",
"]",
".",
"x",
";",
"event",
".",
"clientY",
"=",
"elementPosition",
"[",
"0",
"]",
".",
"y",
";",
"}",
"}",
"if",
"(",
"this",
".",
"_dragStartPosition",
"&&",
"!",
"this",
".",
"_dragStarted",
")",
"{",
"this",
".",
"_startDrag",
"(",
"this",
".",
"_dragStartPosition",
")",
";",
"}",
"var",
"element",
"=",
"this",
".",
"_activeDrag",
";",
"if",
"(",
"element",
")",
"{",
"if",
"(",
"evt",
".",
"type",
"!==",
"\"touchmove\"",
"&&",
"!",
"evt",
".",
"button",
")",
"{",
"var",
"browser",
"=",
"ariaCoreBrowser",
";",
"if",
"(",
"browser",
".",
"isIE8",
"||",
"browser",
".",
"isIE7",
")",
"{",
"event",
".",
"$dispose",
"(",
")",
";",
"return",
"this",
".",
"_onMouseUp",
"(",
"evt",
")",
";",
"}",
"}",
"element",
".",
"move",
"(",
"event",
")",
";",
"}",
"event",
".",
"$dispose",
"(",
")",
";",
"}"
]
| Listener for the mouse move event.
@param {HTMLEvent} evt mouse event. It is not wrapped yet
@private | [
"Listener",
"for",
"the",
"mouse",
"move",
"event",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Mouse.js#L343-L372 | train |
|
ariatemplates/ariatemplates | src/aria/utils/Mouse.js | function (evt) {
this._dragStartPosition = null;
disconnectMouseEvents(this);
var element = this._activeDrag;
if (element) {
element.end();
}
this._candidateForDrag = null;
this._activeDrag = null;
} | javascript | function (evt) {
this._dragStartPosition = null;
disconnectMouseEvents(this);
var element = this._activeDrag;
if (element) {
element.end();
}
this._candidateForDrag = null;
this._activeDrag = null;
} | [
"function",
"(",
"evt",
")",
"{",
"this",
".",
"_dragStartPosition",
"=",
"null",
";",
"disconnectMouseEvents",
"(",
"this",
")",
";",
"var",
"element",
"=",
"this",
".",
"_activeDrag",
";",
"if",
"(",
"element",
")",
"{",
"element",
".",
"end",
"(",
")",
";",
"}",
"this",
".",
"_candidateForDrag",
"=",
"null",
";",
"this",
".",
"_activeDrag",
"=",
"null",
";",
"}"
]
| Listener for the mouse up event.
@param {HTMLEvent} evt mouse event. It is not wrapped yet
@private | [
"Listener",
"for",
"the",
"mouse",
"up",
"event",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Mouse.js#L379-L390 | train |
|
ariatemplates/ariatemplates | src/aria/utils/overlay/Overlay.js | function (element, overlay) {
// --------------------------------------------------- destructuring
var window = Aria.$window;
var document = window.document;
var body = document.body;
// ------------------------------------------------- local functions
function getStyle(element, property) {
return ariaUtilsDom.getStyle(element, property);
}
function getZIndex(element) {
return getStyle(element, 'zIndex');
}
function createsANewStackingContext(element) {
var zIndex = getZIndex(element);
var position = getStyle(element, 'position');
var opacity = getStyle(element, 'opacity');
return (opacity < 1) || ((zIndex !== 'auto') && (position !== 'static'));
}
// ------------------------------------------------------ processing
var zIndexToBeat = null;
// building parent branch ------------------------------------------
var ancestors = [];
var currentElement = element;
while (currentElement !== body && currentElement != null) {
ancestors.unshift(currentElement);
currentElement = currentElement.parentNode;
}
// checking parent branch ------------------------------------------
// only the first (top-most) parent has to be taken into account, further children then being contained in its new stacking context
for (var index = 0, length = ancestors.length; index < length; index++) {
var potentialStackingContextRoot = ancestors[index];
if (createsANewStackingContext(potentialStackingContextRoot)) {
zIndexToBeat = getZIndex(potentialStackingContextRoot);
break;
}
}
// checking children if necessary ----------------------------------
if (zIndexToBeat == null) {
var getMax = function(values) {
return values.length === 0 ? null : Math.max.apply(Math, values);
};
var isANumber = function(value) {
return !isNaN(value);
};
var stackingContexts = [];
var findChildrenCreatingANewStackingContext = function(root) {
var children = root.children;
for (var index = 0, length = children.length; index < length; index++) {
var child = children[index];
if (createsANewStackingContext(child)) {
stackingContexts.push(child);
} else {
findChildrenCreatingANewStackingContext(child);
}
}
};
findChildrenCreatingANewStackingContext(element);
var zIndexes = [];
for (var index = 0, length = stackingContexts.length; index < length; index++) {
var stackingContext = stackingContexts[index];
var currentZIndex = getZIndex(stackingContext);
if (isANumber(currentZIndex)) {
zIndexes.push(currentZIndex);
}
}
zIndexToBeat = getMax(zIndexes);
}
// final zindex application ----------------------------------------
// Our overlay element is put at last in the DOM, so if there is no other stacking context found, there is no need to put a zIndex ourselves since the natural stacking order will apply.
// However, still due to the natural stacking order applied within a same stacking context, there's no need to put a higher zIndex than the top-most stacking context's root, putting the same is sufficient
if (zIndexToBeat !== null) {
overlay.style.zIndex = '' + zIndexToBeat;
}
} | javascript | function (element, overlay) {
// --------------------------------------------------- destructuring
var window = Aria.$window;
var document = window.document;
var body = document.body;
// ------------------------------------------------- local functions
function getStyle(element, property) {
return ariaUtilsDom.getStyle(element, property);
}
function getZIndex(element) {
return getStyle(element, 'zIndex');
}
function createsANewStackingContext(element) {
var zIndex = getZIndex(element);
var position = getStyle(element, 'position');
var opacity = getStyle(element, 'opacity');
return (opacity < 1) || ((zIndex !== 'auto') && (position !== 'static'));
}
// ------------------------------------------------------ processing
var zIndexToBeat = null;
// building parent branch ------------------------------------------
var ancestors = [];
var currentElement = element;
while (currentElement !== body && currentElement != null) {
ancestors.unshift(currentElement);
currentElement = currentElement.parentNode;
}
// checking parent branch ------------------------------------------
// only the first (top-most) parent has to be taken into account, further children then being contained in its new stacking context
for (var index = 0, length = ancestors.length; index < length; index++) {
var potentialStackingContextRoot = ancestors[index];
if (createsANewStackingContext(potentialStackingContextRoot)) {
zIndexToBeat = getZIndex(potentialStackingContextRoot);
break;
}
}
// checking children if necessary ----------------------------------
if (zIndexToBeat == null) {
var getMax = function(values) {
return values.length === 0 ? null : Math.max.apply(Math, values);
};
var isANumber = function(value) {
return !isNaN(value);
};
var stackingContexts = [];
var findChildrenCreatingANewStackingContext = function(root) {
var children = root.children;
for (var index = 0, length = children.length; index < length; index++) {
var child = children[index];
if (createsANewStackingContext(child)) {
stackingContexts.push(child);
} else {
findChildrenCreatingANewStackingContext(child);
}
}
};
findChildrenCreatingANewStackingContext(element);
var zIndexes = [];
for (var index = 0, length = stackingContexts.length; index < length; index++) {
var stackingContext = stackingContexts[index];
var currentZIndex = getZIndex(stackingContext);
if (isANumber(currentZIndex)) {
zIndexes.push(currentZIndex);
}
}
zIndexToBeat = getMax(zIndexes);
}
// final zindex application ----------------------------------------
// Our overlay element is put at last in the DOM, so if there is no other stacking context found, there is no need to put a zIndex ourselves since the natural stacking order will apply.
// However, still due to the natural stacking order applied within a same stacking context, there's no need to put a higher zIndex than the top-most stacking context's root, putting the same is sufficient
if (zIndexToBeat !== null) {
overlay.style.zIndex = '' + zIndexToBeat;
}
} | [
"function",
"(",
"element",
",",
"overlay",
")",
"{",
"var",
"window",
"=",
"Aria",
".",
"$window",
";",
"var",
"document",
"=",
"window",
".",
"document",
";",
"var",
"body",
"=",
"document",
".",
"body",
";",
"function",
"getStyle",
"(",
"element",
",",
"property",
")",
"{",
"return",
"ariaUtilsDom",
".",
"getStyle",
"(",
"element",
",",
"property",
")",
";",
"}",
"function",
"getZIndex",
"(",
"element",
")",
"{",
"return",
"getStyle",
"(",
"element",
",",
"'zIndex'",
")",
";",
"}",
"function",
"createsANewStackingContext",
"(",
"element",
")",
"{",
"var",
"zIndex",
"=",
"getZIndex",
"(",
"element",
")",
";",
"var",
"position",
"=",
"getStyle",
"(",
"element",
",",
"'position'",
")",
";",
"var",
"opacity",
"=",
"getStyle",
"(",
"element",
",",
"'opacity'",
")",
";",
"return",
"(",
"opacity",
"<",
"1",
")",
"||",
"(",
"(",
"zIndex",
"!==",
"'auto'",
")",
"&&",
"(",
"position",
"!==",
"'static'",
")",
")",
";",
"}",
"var",
"zIndexToBeat",
"=",
"null",
";",
"var",
"ancestors",
"=",
"[",
"]",
";",
"var",
"currentElement",
"=",
"element",
";",
"while",
"(",
"currentElement",
"!==",
"body",
"&&",
"currentElement",
"!=",
"null",
")",
"{",
"ancestors",
".",
"unshift",
"(",
"currentElement",
")",
";",
"currentElement",
"=",
"currentElement",
".",
"parentNode",
";",
"}",
"for",
"(",
"var",
"index",
"=",
"0",
",",
"length",
"=",
"ancestors",
".",
"length",
";",
"index",
"<",
"length",
";",
"index",
"++",
")",
"{",
"var",
"potentialStackingContextRoot",
"=",
"ancestors",
"[",
"index",
"]",
";",
"if",
"(",
"createsANewStackingContext",
"(",
"potentialStackingContextRoot",
")",
")",
"{",
"zIndexToBeat",
"=",
"getZIndex",
"(",
"potentialStackingContextRoot",
")",
";",
"break",
";",
"}",
"}",
"if",
"(",
"zIndexToBeat",
"==",
"null",
")",
"{",
"var",
"getMax",
"=",
"function",
"(",
"values",
")",
"{",
"return",
"values",
".",
"length",
"===",
"0",
"?",
"null",
":",
"Math",
".",
"max",
".",
"apply",
"(",
"Math",
",",
"values",
")",
";",
"}",
";",
"var",
"isANumber",
"=",
"function",
"(",
"value",
")",
"{",
"return",
"!",
"isNaN",
"(",
"value",
")",
";",
"}",
";",
"var",
"stackingContexts",
"=",
"[",
"]",
";",
"var",
"findChildrenCreatingANewStackingContext",
"=",
"function",
"(",
"root",
")",
"{",
"var",
"children",
"=",
"root",
".",
"children",
";",
"for",
"(",
"var",
"index",
"=",
"0",
",",
"length",
"=",
"children",
".",
"length",
";",
"index",
"<",
"length",
";",
"index",
"++",
")",
"{",
"var",
"child",
"=",
"children",
"[",
"index",
"]",
";",
"if",
"(",
"createsANewStackingContext",
"(",
"child",
")",
")",
"{",
"stackingContexts",
".",
"push",
"(",
"child",
")",
";",
"}",
"else",
"{",
"findChildrenCreatingANewStackingContext",
"(",
"child",
")",
";",
"}",
"}",
"}",
";",
"findChildrenCreatingANewStackingContext",
"(",
"element",
")",
";",
"var",
"zIndexes",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"index",
"=",
"0",
",",
"length",
"=",
"stackingContexts",
".",
"length",
";",
"index",
"<",
"length",
";",
"index",
"++",
")",
"{",
"var",
"stackingContext",
"=",
"stackingContexts",
"[",
"index",
"]",
";",
"var",
"currentZIndex",
"=",
"getZIndex",
"(",
"stackingContext",
")",
";",
"if",
"(",
"isANumber",
"(",
"currentZIndex",
")",
")",
"{",
"zIndexes",
".",
"push",
"(",
"currentZIndex",
")",
";",
"}",
"}",
"zIndexToBeat",
"=",
"getMax",
"(",
"zIndexes",
")",
";",
"}",
"if",
"(",
"zIndexToBeat",
"!==",
"null",
")",
"{",
"overlay",
".",
"style",
".",
"zIndex",
"=",
"''",
"+",
"zIndexToBeat",
";",
"}",
"}"
]
| Apply a zIndex to the overlay
<p>Resources: </p>
<ul>
<li><a href="http://www.cssmojo.com/everything_you_always_wanted_to_know_about_z-index_but_were_afraid_to_ask/">Find out how elements stack and start using low z-index values</a></li>
<li><a href="https://philipwalton.com/articles/what-no-one-told-you-about-z-index/">What No One Told You About Z-Index — Philip Walton</a></li>
</ul>
@param {HTMLElement} element Reference zIndex
@param {HTMLElement} overlay DOM element of the overlay
@protected | [
"Apply",
"a",
"zIndex",
"to",
"the",
"overlay"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/overlay/Overlay.js#L159-L257 | train |
|
ariatemplates/ariatemplates | src/aria/core/log/AjaxAppender.js | function (className, msg, level) {
var logObject = {
classpath : className,
msg : msg,
level : level,
time : new Date().getTime()
};
this._logStack.push(logObject);
this._processStack();
} | javascript | function (className, msg, level) {
var logObject = {
classpath : className,
msg : msg,
level : level,
time : new Date().getTime()
};
this._logStack.push(logObject);
this._processStack();
} | [
"function",
"(",
"className",
",",
"msg",
",",
"level",
")",
"{",
"var",
"logObject",
"=",
"{",
"classpath",
":",
"className",
",",
"msg",
":",
"msg",
",",
"level",
":",
"level",
",",
"time",
":",
"new",
"Date",
"(",
")",
".",
"getTime",
"(",
")",
"}",
";",
"this",
".",
"_logStack",
".",
"push",
"(",
"logObject",
")",
";",
"this",
".",
"_processStack",
"(",
")",
";",
"}"
]
| Stack a new log entry in the internal stack. This method will then ask to process the stack.
@private
@param {String} className The classname of the object sending the log
@param {String} msg The message
@param {String} level The level | [
"Stack",
"a",
"new",
"log",
"entry",
"in",
"the",
"internal",
"stack",
".",
"This",
"method",
"will",
"then",
"ask",
"to",
"process",
"the",
"stack",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/log/AjaxAppender.js#L49-L58 | train |
|
ariatemplates/ariatemplates | src/aria/core/log/AjaxAppender.js | function () {
// The strategy to send logs is either after a certain delay, or when the stack is bigger than ...
var now = new Date().getTime();
if (this._logStack.length > this.minimumLogNb && now > this._lastLogSent + this.minimumInterval) {
this._lastLogSent = new Date().getTime();
this._sendStack();
this._logStack = [];
}
} | javascript | function () {
// The strategy to send logs is either after a certain delay, or when the stack is bigger than ...
var now = new Date().getTime();
if (this._logStack.length > this.minimumLogNb && now > this._lastLogSent + this.minimumInterval) {
this._lastLogSent = new Date().getTime();
this._sendStack();
this._logStack = [];
}
} | [
"function",
"(",
")",
"{",
"var",
"now",
"=",
"new",
"Date",
"(",
")",
".",
"getTime",
"(",
")",
";",
"if",
"(",
"this",
".",
"_logStack",
".",
"length",
">",
"this",
".",
"minimumLogNb",
"&&",
"now",
">",
"this",
".",
"_lastLogSent",
"+",
"this",
".",
"minimumInterval",
")",
"{",
"this",
".",
"_lastLogSent",
"=",
"new",
"Date",
"(",
")",
".",
"getTime",
"(",
")",
";",
"this",
".",
"_sendStack",
"(",
")",
";",
"this",
".",
"_logStack",
"=",
"[",
"]",
";",
"}",
"}"
]
| Process the stack. Ask to send the request to the server according to the minim delay and minimum number of
logs. Flush the stack if request sent.
@private | [
"Process",
"the",
"stack",
".",
"Ask",
"to",
"send",
"the",
"request",
"to",
"the",
"server",
"according",
"to",
"the",
"minim",
"delay",
"and",
"minimum",
"number",
"of",
"logs",
".",
"Flush",
"the",
"stack",
"if",
"request",
"sent",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/log/AjaxAppender.js#L65-L73 | train |
|
ariatemplates/ariatemplates | src/aria/core/log/AjaxAppender.js | function () {
// stringify the json data
var data = ariaUtilsJson.convertToJsonString({
logs : this._logStack
}, {
maxDepth : 4
});
// Send json post request
ariaCoreIO.asyncRequest({
sender : {
classpath : this.$classpath
},
url : this.url,
method : "POST",
data : data,
callback : {
fn : this._stackSent,
scope : this
}
});
} | javascript | function () {
// stringify the json data
var data = ariaUtilsJson.convertToJsonString({
logs : this._logStack
}, {
maxDepth : 4
});
// Send json post request
ariaCoreIO.asyncRequest({
sender : {
classpath : this.$classpath
},
url : this.url,
method : "POST",
data : data,
callback : {
fn : this._stackSent,
scope : this
}
});
} | [
"function",
"(",
")",
"{",
"var",
"data",
"=",
"ariaUtilsJson",
".",
"convertToJsonString",
"(",
"{",
"logs",
":",
"this",
".",
"_logStack",
"}",
",",
"{",
"maxDepth",
":",
"4",
"}",
")",
";",
"ariaCoreIO",
".",
"asyncRequest",
"(",
"{",
"sender",
":",
"{",
"classpath",
":",
"this",
".",
"$classpath",
"}",
",",
"url",
":",
"this",
".",
"url",
",",
"method",
":",
"\"POST\"",
",",
"data",
":",
"data",
",",
"callback",
":",
"{",
"fn",
":",
"this",
".",
"_stackSent",
",",
"scope",
":",
"this",
"}",
"}",
")",
";",
"}"
]
| Actually send the stack to the server. See aria.core.IO. | [
"Actually",
"send",
"the",
"stack",
"to",
"the",
"server",
".",
"See",
"aria",
".",
"core",
".",
"IO",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/log/AjaxAppender.js#L78-L99 | train |
|
ariatemplates/ariatemplates | src/aria/core/log/AjaxAppender.js | function (e) {
var str = "";
if (typeof e == 'undefined' || e == null) {
return str;
}
str = "\nException";
str += "\n" + '---------------------------------------------------';
if (e.fileName)
str += '\nFile: ' + e.fileName;
if (e.lineNumber)
str += '\nLine: ' + e.lineNumber;
if (e.message)
str += '\nMessage: ' + e.message;
if (e.name)
str += '\nError: ' + e.name;
if (e.stack)
str += '\nStack:' + "\n" + e.stack.substring(0, 200) + " [...] Truncated stacktrace.";
str += "\n" + '---------------------------------------------------' + "\n";
return str;
} | javascript | function (e) {
var str = "";
if (typeof e == 'undefined' || e == null) {
return str;
}
str = "\nException";
str += "\n" + '---------------------------------------------------';
if (e.fileName)
str += '\nFile: ' + e.fileName;
if (e.lineNumber)
str += '\nLine: ' + e.lineNumber;
if (e.message)
str += '\nMessage: ' + e.message;
if (e.name)
str += '\nError: ' + e.name;
if (e.stack)
str += '\nStack:' + "\n" + e.stack.substring(0, 200) + " [...] Truncated stacktrace.";
str += "\n" + '---------------------------------------------------' + "\n";
return str;
} | [
"function",
"(",
"e",
")",
"{",
"var",
"str",
"=",
"\"\"",
";",
"if",
"(",
"typeof",
"e",
"==",
"'undefined'",
"||",
"e",
"==",
"null",
")",
"{",
"return",
"str",
";",
"}",
"str",
"=",
"\"\\nException\"",
";",
"\\n",
"str",
"+=",
"\"\\n\"",
"+",
"\\n",
";",
"'---------------------------------------------------'",
"if",
"(",
"e",
".",
"fileName",
")",
"str",
"+=",
"'\\nFile: '",
"+",
"\\n",
";",
"e",
".",
"fileName",
"if",
"(",
"e",
".",
"lineNumber",
")",
"str",
"+=",
"'\\nLine: '",
"+",
"\\n",
";",
"e",
".",
"lineNumber",
"if",
"(",
"e",
".",
"message",
")",
"str",
"+=",
"'\\nMessage: '",
"+",
"\\n",
";",
"}"
]
| Format an exception object
@param {Object} e The exception to format
@return {String} The message ready to be shown
@private | [
"Format",
"an",
"exception",
"object"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/log/AjaxAppender.js#L156-L178 | train |
|
ariatemplates/ariatemplates | src/aria/widgets/container/Splitter.js | function (element, orientation) {
if (element.style && element.color) {
if (orientation == "V") {
return element.leftWidth + element.rightWidth;
} else if (orientation == "H") {
return element.topWidth + element.bottomWidth;
}
}
return 0;
} | javascript | function (element, orientation) {
if (element.style && element.color) {
if (orientation == "V") {
return element.leftWidth + element.rightWidth;
} else if (orientation == "H") {
return element.topWidth + element.bottomWidth;
}
}
return 0;
} | [
"function",
"(",
"element",
",",
"orientation",
")",
"{",
"if",
"(",
"element",
".",
"style",
"&&",
"element",
".",
"color",
")",
"{",
"if",
"(",
"orientation",
"==",
"\"V\"",
")",
"{",
"return",
"element",
".",
"leftWidth",
"+",
"element",
".",
"rightWidth",
";",
"}",
"else",
"if",
"(",
"orientation",
"==",
"\"H\"",
")",
"{",
"return",
"element",
".",
"topWidth",
"+",
"element",
".",
"bottomWidth",
";",
"}",
"}",
"return",
"0",
";",
"}"
]
| calculate the border size of an element
@param {aria.widgets.CfgBeans:BorderCfg}
@param {String} H, V
@return {Number} border size | [
"calculate",
"the",
"border",
"size",
"of",
"an",
"element"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/container/Splitter.js#L353-L362 | train |
|
ariatemplates/ariatemplates | src/aria/core/JsObject.js | function (allInterceptors, name, scope, fn) {
for (var i in allInterceptors[name]) {
if (allInterceptors[name].hasOwnProperty(i)) {
__removeCallback(allInterceptors[name], i, scope, fn);
}
}
} | javascript | function (allInterceptors, name, scope, fn) {
for (var i in allInterceptors[name]) {
if (allInterceptors[name].hasOwnProperty(i)) {
__removeCallback(allInterceptors[name], i, scope, fn);
}
}
} | [
"function",
"(",
"allInterceptors",
",",
"name",
",",
"scope",
",",
"fn",
")",
"{",
"for",
"(",
"var",
"i",
"in",
"allInterceptors",
"[",
"name",
"]",
")",
"{",
"if",
"(",
"allInterceptors",
"[",
"name",
"]",
".",
"hasOwnProperty",
"(",
"i",
")",
")",
"{",
"__removeCallback",
"(",
"allInterceptors",
"[",
"name",
"]",
",",
"i",
",",
"scope",
",",
"fn",
")",
";",
"}",
"}",
"}"
]
| Private method to remove interceptors.
@param {Object} allInterceptors obj.__$interceptors
@param {String} name [mandatory] name interface name
@param {Object} scope [optional] if specified, only interceptors with that scope will be removed
@param {Function} fn [optional] if specified, only interceptors with that function will be removed | [
"Private",
"method",
"to",
"remove",
"interceptors",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/JsObject.js#L28-L34 | train |
|
ariatemplates/ariatemplates | src/aria/core/JsObject.js | function (callbacksMap, name, scope, fn, src, firstOnly) {
if (callbacksMap == null) {
return; // nothing to remove
}
var arr = callbacksMap[name];
if (arr) {
var length = arr.length, removeThis = false, cb;
for (var i = 0; i < length; i++) {
cb = arr[i];
// determine if callback should be removed, start with
// removeThis = true and then set to false if
// conditions are not met
// check the interface from which we remove the listener
removeThis = (!src || cb.src == src)
// scope does not match
&& (!scope || scope == cb.scope)
// fn does not match
&& (!fn || fn == cb.fn);
if (removeThis) {
// mark the callback as being removed, so that it can either
// still be called (in case of CallEnd in
// interceptors, if CallBegin has been called) or not called
// at all (in other cases)
cb.removed = true;
arr.splice(i, 1);
if (firstOnly) {
break;
} else {
i--;
length--;
}
}
}
if (arr.length === 0) {
// no listener anymore for this event/interface
callbacksMap[name] = null;
delete callbacksMap[name];
}
}
} | javascript | function (callbacksMap, name, scope, fn, src, firstOnly) {
if (callbacksMap == null) {
return; // nothing to remove
}
var arr = callbacksMap[name];
if (arr) {
var length = arr.length, removeThis = false, cb;
for (var i = 0; i < length; i++) {
cb = arr[i];
// determine if callback should be removed, start with
// removeThis = true and then set to false if
// conditions are not met
// check the interface from which we remove the listener
removeThis = (!src || cb.src == src)
// scope does not match
&& (!scope || scope == cb.scope)
// fn does not match
&& (!fn || fn == cb.fn);
if (removeThis) {
// mark the callback as being removed, so that it can either
// still be called (in case of CallEnd in
// interceptors, if CallBegin has been called) or not called
// at all (in other cases)
cb.removed = true;
arr.splice(i, 1);
if (firstOnly) {
break;
} else {
i--;
length--;
}
}
}
if (arr.length === 0) {
// no listener anymore for this event/interface
callbacksMap[name] = null;
delete callbacksMap[name];
}
}
} | [
"function",
"(",
"callbacksMap",
",",
"name",
",",
"scope",
",",
"fn",
",",
"src",
",",
"firstOnly",
")",
"{",
"if",
"(",
"callbacksMap",
"==",
"null",
")",
"{",
"return",
";",
"}",
"var",
"arr",
"=",
"callbacksMap",
"[",
"name",
"]",
";",
"if",
"(",
"arr",
")",
"{",
"var",
"length",
"=",
"arr",
".",
"length",
",",
"removeThis",
"=",
"false",
",",
"cb",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"cb",
"=",
"arr",
"[",
"i",
"]",
";",
"removeThis",
"=",
"(",
"!",
"src",
"||",
"cb",
".",
"src",
"==",
"src",
")",
"&&",
"(",
"!",
"scope",
"||",
"scope",
"==",
"cb",
".",
"scope",
")",
"&&",
"(",
"!",
"fn",
"||",
"fn",
"==",
"cb",
".",
"fn",
")",
";",
"if",
"(",
"removeThis",
")",
"{",
"cb",
".",
"removed",
"=",
"true",
";",
"arr",
".",
"splice",
"(",
"i",
",",
"1",
")",
";",
"if",
"(",
"firstOnly",
")",
"{",
"break",
";",
"}",
"else",
"{",
"i",
"--",
";",
"length",
"--",
";",
"}",
"}",
"}",
"if",
"(",
"arr",
".",
"length",
"===",
"0",
")",
"{",
"callbacksMap",
"[",
"name",
"]",
"=",
"null",
";",
"delete",
"callbacksMap",
"[",
"name",
"]",
";",
"}",
"}",
"}"
]
| Private method used to remove callbacks from a map of callbacks associated to a given scope and function
@param {Object} callbacksMap map of callbacks, which can be currently: obj._listeners
@param {String} name [mandatory] name in the map, may be the event name (if callbacksMap == _listeners)
@param {Object} scope [optional] if specified, only callbacks with that scope will be removed
@param {Function} fn [optional] if specified, only callbacks with that function will be removed
@param {Object} src [optional] if the method is called from an interface wrapper, must be the reference of the
interface wrapper. It is used to restrict the callbacks which can be removed from the map.
@param {Boolean} firstOnly. if true, remove only first occurence.
@private | [
"Private",
"method",
"used",
"to",
"remove",
"callbacks",
"from",
"a",
"map",
"of",
"callbacks",
"associated",
"to",
"a",
"given",
"scope",
"and",
"function"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/JsObject.js#L47-L91 | train |
|
ariatemplates/ariatemplates | src/aria/core/JsObject.js | function (info) {
var methodName = require("../utils/String").capitalize(info.method);
var fctRef = this["on" + methodName + info.step];
if (fctRef) {
return fctRef.call(this, info);
}
fctRef = this["on" + info.method + info.step];
if (fctRef) {
return fctRef.call(this, info);
}
} | javascript | function (info) {
var methodName = require("../utils/String").capitalize(info.method);
var fctRef = this["on" + methodName + info.step];
if (fctRef) {
return fctRef.call(this, info);
}
fctRef = this["on" + info.method + info.step];
if (fctRef) {
return fctRef.call(this, info);
}
} | [
"function",
"(",
"info",
")",
"{",
"var",
"methodName",
"=",
"require",
"(",
"\"../utils/String\"",
")",
".",
"capitalize",
"(",
"info",
".",
"method",
")",
";",
"var",
"fctRef",
"=",
"this",
"[",
"\"on\"",
"+",
"methodName",
"+",
"info",
".",
"step",
"]",
";",
"if",
"(",
"fctRef",
")",
"{",
"return",
"fctRef",
".",
"call",
"(",
"this",
",",
"info",
")",
";",
"}",
"fctRef",
"=",
"this",
"[",
"\"on\"",
"+",
"info",
".",
"method",
"+",
"info",
".",
"step",
"]",
";",
"if",
"(",
"fctRef",
")",
"{",
"return",
"fctRef",
".",
"call",
"(",
"this",
",",
"info",
")",
";",
"}",
"}"
]
| Interceptor dispatch function.
@param {Object} interc interceptor instance
@param {Object} info interceptor parameters | [
"Interceptor",
"dispatch",
"function",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/JsObject.js#L98-L108 | train |
|
ariatemplates/ariatemplates | src/aria/core/JsObject.js | function (args, commonInfo, interceptorIndex) {
if (interceptorIndex >= commonInfo.nbInterceptors) {
// end of recursion: call the real method:
return this[commonInfo.method].apply(this, args);
}
var interc = commonInfo.interceptors[interceptorIndex];
if (interc.removed) {
// interceptor was removed in the mean time, skip it.
return __callWrapper.call(this, info.args, commonInfo, interceptorIndex + 1);
}
var info = {
step : "CallBegin",
method : commonInfo.method,
args : args,
cancelDefault : false,
returnValue : null
};
var asyncCbParam = commonInfo.asyncCbParam;
if (asyncCbParam != null) {
var callback = {
fn : __callbackWrapper,
scope : this,
args : {
info : info,
interc : interc,
// save previous callback:
origCb : args[asyncCbParam]
}
};
args[asyncCbParam] = callback;
if (args.length <= asyncCbParam) {
// We do this check and set the length property because the
// "args" object comes
// from the JavaScript arguments object, which is not a real
// array so that the
// length property is not updated automatically by the previous
// assignation: args[asyncCbParam] = callback;
args.length = asyncCbParam + 1;
}
info.callback = callback;
}
this.$callback(interc, info);
if (!info.cancelDefault) {
// call next wrapper or real method:
try {
info.returnValue = __callWrapper.call(this, info.args, commonInfo, interceptorIndex + 1);
} catch (e) {
info.exception = e;
}
info.step = "CallEnd";
delete info.cancelDefault; // no longer useful in CallEnd
// call the interceptor, even if it was removed in the mean time (so
// that CallEnd is always called when
// CallBegin has been called):
this.$callback(interc, info);
if ("exception" in info) {
throw info.exception;
}
}
return info.returnValue;
} | javascript | function (args, commonInfo, interceptorIndex) {
if (interceptorIndex >= commonInfo.nbInterceptors) {
// end of recursion: call the real method:
return this[commonInfo.method].apply(this, args);
}
var interc = commonInfo.interceptors[interceptorIndex];
if (interc.removed) {
// interceptor was removed in the mean time, skip it.
return __callWrapper.call(this, info.args, commonInfo, interceptorIndex + 1);
}
var info = {
step : "CallBegin",
method : commonInfo.method,
args : args,
cancelDefault : false,
returnValue : null
};
var asyncCbParam = commonInfo.asyncCbParam;
if (asyncCbParam != null) {
var callback = {
fn : __callbackWrapper,
scope : this,
args : {
info : info,
interc : interc,
// save previous callback:
origCb : args[asyncCbParam]
}
};
args[asyncCbParam] = callback;
if (args.length <= asyncCbParam) {
// We do this check and set the length property because the
// "args" object comes
// from the JavaScript arguments object, which is not a real
// array so that the
// length property is not updated automatically by the previous
// assignation: args[asyncCbParam] = callback;
args.length = asyncCbParam + 1;
}
info.callback = callback;
}
this.$callback(interc, info);
if (!info.cancelDefault) {
// call next wrapper or real method:
try {
info.returnValue = __callWrapper.call(this, info.args, commonInfo, interceptorIndex + 1);
} catch (e) {
info.exception = e;
}
info.step = "CallEnd";
delete info.cancelDefault; // no longer useful in CallEnd
// call the interceptor, even if it was removed in the mean time (so
// that CallEnd is always called when
// CallBegin has been called):
this.$callback(interc, info);
if ("exception" in info) {
throw info.exception;
}
}
return info.returnValue;
} | [
"function",
"(",
"args",
",",
"commonInfo",
",",
"interceptorIndex",
")",
"{",
"if",
"(",
"interceptorIndex",
">=",
"commonInfo",
".",
"nbInterceptors",
")",
"{",
"return",
"this",
"[",
"commonInfo",
".",
"method",
"]",
".",
"apply",
"(",
"this",
",",
"args",
")",
";",
"}",
"var",
"interc",
"=",
"commonInfo",
".",
"interceptors",
"[",
"interceptorIndex",
"]",
";",
"if",
"(",
"interc",
".",
"removed",
")",
"{",
"return",
"__callWrapper",
".",
"call",
"(",
"this",
",",
"info",
".",
"args",
",",
"commonInfo",
",",
"interceptorIndex",
"+",
"1",
")",
";",
"}",
"var",
"info",
"=",
"{",
"step",
":",
"\"CallBegin\"",
",",
"method",
":",
"commonInfo",
".",
"method",
",",
"args",
":",
"args",
",",
"cancelDefault",
":",
"false",
",",
"returnValue",
":",
"null",
"}",
";",
"var",
"asyncCbParam",
"=",
"commonInfo",
".",
"asyncCbParam",
";",
"if",
"(",
"asyncCbParam",
"!=",
"null",
")",
"{",
"var",
"callback",
"=",
"{",
"fn",
":",
"__callbackWrapper",
",",
"scope",
":",
"this",
",",
"args",
":",
"{",
"info",
":",
"info",
",",
"interc",
":",
"interc",
",",
"origCb",
":",
"args",
"[",
"asyncCbParam",
"]",
"}",
"}",
";",
"args",
"[",
"asyncCbParam",
"]",
"=",
"callback",
";",
"if",
"(",
"args",
".",
"length",
"<=",
"asyncCbParam",
")",
"{",
"args",
".",
"length",
"=",
"asyncCbParam",
"+",
"1",
";",
"}",
"info",
".",
"callback",
"=",
"callback",
";",
"}",
"this",
".",
"$callback",
"(",
"interc",
",",
"info",
")",
";",
"if",
"(",
"!",
"info",
".",
"cancelDefault",
")",
"{",
"try",
"{",
"info",
".",
"returnValue",
"=",
"__callWrapper",
".",
"call",
"(",
"this",
",",
"info",
".",
"args",
",",
"commonInfo",
",",
"interceptorIndex",
"+",
"1",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"info",
".",
"exception",
"=",
"e",
";",
"}",
"info",
".",
"step",
"=",
"\"CallEnd\"",
";",
"delete",
"info",
".",
"cancelDefault",
";",
"this",
".",
"$callback",
"(",
"interc",
",",
"info",
")",
";",
"if",
"(",
"\"exception\"",
"in",
"info",
")",
"{",
"throw",
"info",
".",
"exception",
";",
"}",
"}",
"return",
"info",
".",
"returnValue",
";",
"}"
]
| Recursive method to call wrappers. This method should be called with "this" refering to the object whose method
is called. | [
"Recursive",
"method",
"to",
"call",
"wrappers",
".",
"This",
"method",
"should",
"be",
"called",
"with",
"this",
"refering",
"to",
"the",
"object",
"whose",
"method",
"is",
"called",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/JsObject.js#L114-L174 | train |
|
ariatemplates/ariatemplates | src/aria/core/JsObject.js | function (res, args) {
var interc = args.interc;
if (interc.removed) {
// the interceptor was removed in the mean time, call the original callback directly
return this.$callback(args.origCb, res);
}
var info = args.info;
info.step = "Callback";
info.callback = args.origCb;
info.callbackResult = res;
info.cancelDefault = false;
info.returnValue = null;
this.$callback(interc, info);
if (info.cancelDefault) {
return info.returnValue;
}
return this.$callback(args.origCb, info.callbackResult);
} | javascript | function (res, args) {
var interc = args.interc;
if (interc.removed) {
// the interceptor was removed in the mean time, call the original callback directly
return this.$callback(args.origCb, res);
}
var info = args.info;
info.step = "Callback";
info.callback = args.origCb;
info.callbackResult = res;
info.cancelDefault = false;
info.returnValue = null;
this.$callback(interc, info);
if (info.cancelDefault) {
return info.returnValue;
}
return this.$callback(args.origCb, info.callbackResult);
} | [
"function",
"(",
"res",
",",
"args",
")",
"{",
"var",
"interc",
"=",
"args",
".",
"interc",
";",
"if",
"(",
"interc",
".",
"removed",
")",
"{",
"return",
"this",
".",
"$callback",
"(",
"args",
".",
"origCb",
",",
"res",
")",
";",
"}",
"var",
"info",
"=",
"args",
".",
"info",
";",
"info",
".",
"step",
"=",
"\"Callback\"",
";",
"info",
".",
"callback",
"=",
"args",
".",
"origCb",
";",
"info",
".",
"callbackResult",
"=",
"res",
";",
"info",
".",
"cancelDefault",
"=",
"false",
";",
"info",
".",
"returnValue",
"=",
"null",
";",
"this",
".",
"$callback",
"(",
"interc",
",",
"info",
")",
";",
"if",
"(",
"info",
".",
"cancelDefault",
")",
"{",
"return",
"info",
".",
"returnValue",
";",
"}",
"return",
"this",
".",
"$callback",
"(",
"args",
".",
"origCb",
",",
"info",
".",
"callbackResult",
")",
";",
"}"
]
| Callback wrapper. | [
"Callback",
"wrapper",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/JsObject.js#L179-L196 | train |
|
ariatemplates/ariatemplates | src/aria/core/JsObject.js | function (interfaceMethods, interceptor, allInterceptors) {
var interceptedMethods = allInterceptors || {};
// for a callback, intercept all methods of an interface
for (var i in interfaceMethods) {
if (interfaceMethods.hasOwnProperty(i)) {
(interceptedMethods[i] || (interceptedMethods[i] = [])).push(interceptor);
}
}
return interceptedMethods;
} | javascript | function (interfaceMethods, interceptor, allInterceptors) {
var interceptedMethods = allInterceptors || {};
// for a callback, intercept all methods of an interface
for (var i in interfaceMethods) {
if (interfaceMethods.hasOwnProperty(i)) {
(interceptedMethods[i] || (interceptedMethods[i] = [])).push(interceptor);
}
}
return interceptedMethods;
} | [
"function",
"(",
"interfaceMethods",
",",
"interceptor",
",",
"allInterceptors",
")",
"{",
"var",
"interceptedMethods",
"=",
"allInterceptors",
"||",
"{",
"}",
";",
"for",
"(",
"var",
"i",
"in",
"interfaceMethods",
")",
"{",
"if",
"(",
"interfaceMethods",
".",
"hasOwnProperty",
"(",
"i",
")",
")",
"{",
"(",
"interceptedMethods",
"[",
"i",
"]",
"||",
"(",
"interceptedMethods",
"[",
"i",
"]",
"=",
"[",
"]",
")",
")",
".",
"push",
"(",
"interceptor",
")",
";",
"}",
"}",
"return",
"interceptedMethods",
";",
"}"
]
| Adds an interceptor to all methods.
@param {Object} interfaceMethods all methods for the interface
@param {aria.core.CfgBeans:Callback} interceptor a callback which will receive notifications
@return {Object} interceptedMethods | [
"Adds",
"an",
"interceptor",
"to",
"all",
"methods",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/JsObject.js#L222-L231 | train |
|
ariatemplates/ariatemplates | src/aria/core/JsObject.js | function (interfaceMethods, interceptor, allInterceptors) {
var interceptedMethods = allInterceptors || {};
// for a class object, intercept specific methods
for (var m in interfaceMethods) {
if (interfaceMethods.hasOwnProperty(m) && __hasBeenIntercepted(m, interceptor)) {
(interceptedMethods[m] || (interceptedMethods[m] = [])).push({
fn : __callInterceptorMethod,
scope : interceptor
});
}
}
return interceptedMethods;
} | javascript | function (interfaceMethods, interceptor, allInterceptors) {
var interceptedMethods = allInterceptors || {};
// for a class object, intercept specific methods
for (var m in interfaceMethods) {
if (interfaceMethods.hasOwnProperty(m) && __hasBeenIntercepted(m, interceptor)) {
(interceptedMethods[m] || (interceptedMethods[m] = [])).push({
fn : __callInterceptorMethod,
scope : interceptor
});
}
}
return interceptedMethods;
} | [
"function",
"(",
"interfaceMethods",
",",
"interceptor",
",",
"allInterceptors",
")",
"{",
"var",
"interceptedMethods",
"=",
"allInterceptors",
"||",
"{",
"}",
";",
"for",
"(",
"var",
"m",
"in",
"interfaceMethods",
")",
"{",
"if",
"(",
"interfaceMethods",
".",
"hasOwnProperty",
"(",
"m",
")",
"&&",
"__hasBeenIntercepted",
"(",
"m",
",",
"interceptor",
")",
")",
"{",
"(",
"interceptedMethods",
"[",
"m",
"]",
"||",
"(",
"interceptedMethods",
"[",
"m",
"]",
"=",
"[",
"]",
")",
")",
".",
"push",
"(",
"{",
"fn",
":",
"__callInterceptorMethod",
",",
"scope",
":",
"interceptor",
"}",
")",
";",
"}",
"}",
"return",
"interceptedMethods",
";",
"}"
]
| Targets specific methods to be intercepted.
@param {Object} interfaceMethods all methods for the interface
@param {Object} interceptor an object/class which will receive notifications
@return {Object} interceptedMethods | [
"Targets",
"specific",
"methods",
"to",
"be",
"intercepted",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/JsObject.js#L239-L251 | train |
|
ariatemplates/ariatemplates | src/aria/core/JsObject.js | function () {
this.$destructor(); // call $destructor
// TODO - cleanup object
if (this._listeners) {
this._listeners = null;
delete this._listeners;
}
if (this.__$interceptors) {
this.__$interceptors = null;
delete this.__$interceptors;
}
if (this.__$interfaces) {
require("./Interfaces").disposeInterfaces(this);
}
} | javascript | function () {
this.$destructor(); // call $destructor
// TODO - cleanup object
if (this._listeners) {
this._listeners = null;
delete this._listeners;
}
if (this.__$interceptors) {
this.__$interceptors = null;
delete this.__$interceptors;
}
if (this.__$interfaces) {
require("./Interfaces").disposeInterfaces(this);
}
} | [
"function",
"(",
")",
"{",
"this",
".",
"$destructor",
"(",
")",
";",
"if",
"(",
"this",
".",
"_listeners",
")",
"{",
"this",
".",
"_listeners",
"=",
"null",
";",
"delete",
"this",
".",
"_listeners",
";",
"}",
"if",
"(",
"this",
".",
"__$interceptors",
")",
"{",
"this",
".",
"__$interceptors",
"=",
"null",
";",
"delete",
"this",
".",
"__$interceptors",
";",
"}",
"if",
"(",
"this",
".",
"__$interfaces",
")",
"{",
"require",
"(",
"\"./Interfaces\"",
")",
".",
"disposeInterfaces",
"(",
"this",
")",
";",
"}",
"}"
]
| Method to call on any object prior to deletion | [
"Method",
"to",
"call",
"on",
"any",
"object",
"prior",
"to",
"deletion"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/JsObject.js#L305-L319 | train |
|
ariatemplates/ariatemplates | src/aria/core/JsObject.js | function (msg, msgArgs, err) {
// replaced by the true logging function when
// aria.core.Log is loaded
// If it's not replaced because the log is never
// downloaded, at least there will be errors in the
// console.
if (Aria.$global.console) {
if (typeof msgArgs === "string")
msgArgs = [msgArgs];
Aria.$global.console.error(msg.replace(/%[0-9]+/g, function (token) {
return msgArgs[parseInt(token.substring(1), 10) - 1];
}), err);
}
return "";
} | javascript | function (msg, msgArgs, err) {
// replaced by the true logging function when
// aria.core.Log is loaded
// If it's not replaced because the log is never
// downloaded, at least there will be errors in the
// console.
if (Aria.$global.console) {
if (typeof msgArgs === "string")
msgArgs = [msgArgs];
Aria.$global.console.error(msg.replace(/%[0-9]+/g, function (token) {
return msgArgs[parseInt(token.substring(1), 10) - 1];
}), err);
}
return "";
} | [
"function",
"(",
"msg",
",",
"msgArgs",
",",
"err",
")",
"{",
"if",
"(",
"Aria",
".",
"$global",
".",
"console",
")",
"{",
"if",
"(",
"typeof",
"msgArgs",
"===",
"\"string\"",
")",
"msgArgs",
"=",
"[",
"msgArgs",
"]",
";",
"Aria",
".",
"$global",
".",
"console",
".",
"error",
"(",
"msg",
".",
"replace",
"(",
"/",
"%[0-9]+",
"/",
"g",
",",
"function",
"(",
"token",
")",
"{",
"return",
"msgArgs",
"[",
"parseInt",
"(",
"token",
".",
"substring",
"(",
"1",
")",
",",
"10",
")",
"-",
"1",
"]",
";",
"}",
")",
",",
"err",
")",
";",
"}",
"return",
"\"\"",
";",
"}"
]
| Log an error message to the logger
@param {String} msg the message text
@param {Array} msgArgs An array of arguments to be used for string replacement in the message text
@param {Object} err The actual JS error object that was created or an object to be inspected in the
logged message | [
"Log",
"an",
"error",
"message",
"to",
"the",
"logger"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/JsObject.js#L382-L396 | train |
|
ariatemplates/ariatemplates | src/aria/core/JsObject.js | function (cb, res, errorId) {
try {
if (!cb) {
return; // callback is sometimes not used
}
if (cb.$Callback) {
return cb.call(res);
}
// perf optimisation : duplicated code on purpose
var scope = cb.scope, callback;
scope = scope ? scope : this;
if (!cb.fn) {
callback = cb;
} else {
callback = cb.fn;
}
if (typeof(callback) == 'string') {
callback = scope[callback];
}
var args = (cb.apply === true && cb.args && Object.prototype.toString.apply(cb.args) === "[object Array]")
? cb.args.slice()
: [cb.args];
var resIndex = (cb.resIndex === undefined) ? 0 : cb.resIndex;
if (resIndex > -1) {
args.splice(resIndex, 0, res);
}
return Function.prototype.apply.call(callback, scope, args);
} catch (ex) {
this.$logError(errorId || this.CALLBACK_ERROR, [this.$classpath, (scope) ? scope.$classpath : ""], ex);
}
} | javascript | function (cb, res, errorId) {
try {
if (!cb) {
return; // callback is sometimes not used
}
if (cb.$Callback) {
return cb.call(res);
}
// perf optimisation : duplicated code on purpose
var scope = cb.scope, callback;
scope = scope ? scope : this;
if (!cb.fn) {
callback = cb;
} else {
callback = cb.fn;
}
if (typeof(callback) == 'string') {
callback = scope[callback];
}
var args = (cb.apply === true && cb.args && Object.prototype.toString.apply(cb.args) === "[object Array]")
? cb.args.slice()
: [cb.args];
var resIndex = (cb.resIndex === undefined) ? 0 : cb.resIndex;
if (resIndex > -1) {
args.splice(resIndex, 0, res);
}
return Function.prototype.apply.call(callback, scope, args);
} catch (ex) {
this.$logError(errorId || this.CALLBACK_ERROR, [this.$classpath, (scope) ? scope.$classpath : ""], ex);
}
} | [
"function",
"(",
"cb",
",",
"res",
",",
"errorId",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"cb",
")",
"{",
"return",
";",
"}",
"if",
"(",
"cb",
".",
"$Callback",
")",
"{",
"return",
"cb",
".",
"call",
"(",
"res",
")",
";",
"}",
"var",
"scope",
"=",
"cb",
".",
"scope",
",",
"callback",
";",
"scope",
"=",
"scope",
"?",
"scope",
":",
"this",
";",
"if",
"(",
"!",
"cb",
".",
"fn",
")",
"{",
"callback",
"=",
"cb",
";",
"}",
"else",
"{",
"callback",
"=",
"cb",
".",
"fn",
";",
"}",
"if",
"(",
"typeof",
"(",
"callback",
")",
"==",
"'string'",
")",
"{",
"callback",
"=",
"scope",
"[",
"callback",
"]",
";",
"}",
"var",
"args",
"=",
"(",
"cb",
".",
"apply",
"===",
"true",
"&&",
"cb",
".",
"args",
"&&",
"Object",
".",
"prototype",
".",
"toString",
".",
"apply",
"(",
"cb",
".",
"args",
")",
"===",
"\"[object Array]\"",
")",
"?",
"cb",
".",
"args",
".",
"slice",
"(",
")",
":",
"[",
"cb",
".",
"args",
"]",
";",
"var",
"resIndex",
"=",
"(",
"cb",
".",
"resIndex",
"===",
"undefined",
")",
"?",
"0",
":",
"cb",
".",
"resIndex",
";",
"if",
"(",
"resIndex",
">",
"-",
"1",
")",
"{",
"args",
".",
"splice",
"(",
"resIndex",
",",
"0",
",",
"res",
")",
";",
"}",
"return",
"Function",
".",
"prototype",
".",
"apply",
".",
"call",
"(",
"callback",
",",
"scope",
",",
"args",
")",
";",
"}",
"catch",
"(",
"ex",
")",
"{",
"this",
".",
"$logError",
"(",
"errorId",
"||",
"this",
".",
"CALLBACK_ERROR",
",",
"[",
"this",
".",
"$classpath",
",",
"(",
"scope",
")",
"?",
"scope",
".",
"$classpath",
":",
"\"\"",
"]",
",",
"ex",
")",
";",
"}",
"}"
]
| Generic method allowing to call-back a caller in asynchronous processes
@param {aria.core.CfgBeans:Callback} cb callback description
@param {MultiTypes} res first result argument to pass to cb.fn (second argument will be cb.args)
@param {String} errorId error raised if an exception occurs in the callback
@return {MultiTypes} the value returned by the callback, or undefined if the callback could not be
called. | [
"Generic",
"method",
"allowing",
"to",
"call",
"-",
"back",
"a",
"caller",
"in",
"asynchronous",
"processes"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/JsObject.js#L406-L442 | train |
|
ariatemplates/ariatemplates | src/aria/core/JsObject.js | function (cb) {
var scope = cb.scope, callback;
scope = scope ? scope : this;
if (!cb.fn) {
callback = cb;
} else {
callback = cb.fn;
}
if (typeof(callback) == 'string') {
callback = scope[callback];
}
return {
fn : callback,
scope : scope,
args : cb.args,
resIndex : cb.resIndex,
apply : cb.apply
};
} | javascript | function (cb) {
var scope = cb.scope, callback;
scope = scope ? scope : this;
if (!cb.fn) {
callback = cb;
} else {
callback = cb.fn;
}
if (typeof(callback) == 'string') {
callback = scope[callback];
}
return {
fn : callback,
scope : scope,
args : cb.args,
resIndex : cb.resIndex,
apply : cb.apply
};
} | [
"function",
"(",
"cb",
")",
"{",
"var",
"scope",
"=",
"cb",
".",
"scope",
",",
"callback",
";",
"scope",
"=",
"scope",
"?",
"scope",
":",
"this",
";",
"if",
"(",
"!",
"cb",
".",
"fn",
")",
"{",
"callback",
"=",
"cb",
";",
"}",
"else",
"{",
"callback",
"=",
"cb",
".",
"fn",
";",
"}",
"if",
"(",
"typeof",
"(",
"callback",
")",
"==",
"'string'",
")",
"{",
"callback",
"=",
"scope",
"[",
"callback",
"]",
";",
"}",
"return",
"{",
"fn",
":",
"callback",
",",
"scope",
":",
"scope",
",",
"args",
":",
"cb",
".",
"args",
",",
"resIndex",
":",
"cb",
".",
"resIndex",
",",
"apply",
":",
"cb",
".",
"apply",
"}",
";",
"}"
]
| Gets a proper signature callback from description given in argument
@param {Object|String} cn callback signature
@return {Object} callback object with fn and scope | [
"Gets",
"a",
"proper",
"signature",
"callback",
"from",
"description",
"given",
"in",
"argument"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/JsObject.js#L449-L468 | train |
|
ariatemplates/ariatemplates | src/aria/core/JsObject.js | function (itf, interceptor) {
// get the interface constructor:
var itfCstr = this.$interfaces[itf];
if (!itfCstr) {
this.$logError(this.INTERFACE_NOT_SUPPORTED, [itf, this.$classpath]);
return;
}
var allInterceptors = this.__$interceptors;
if (allInterceptors == null) {
allInterceptors = {};
this.__$interceptors = allInterceptors;
}
var interceptMethods = ((require("../utils/Type")).isCallback(interceptor))
? __interceptCallback
: __interceptObject;
var itfs = itfCstr.prototype.$interfaces;
for (var i in itfs) {
if (itfs.hasOwnProperty(i)) {
var interceptedMethods = interceptMethods(itfs[i].interfaceDefinition.$interface, interceptor, allInterceptors[i]);
allInterceptors[i] = interceptedMethods;
}
}
} | javascript | function (itf, interceptor) {
// get the interface constructor:
var itfCstr = this.$interfaces[itf];
if (!itfCstr) {
this.$logError(this.INTERFACE_NOT_SUPPORTED, [itf, this.$classpath]);
return;
}
var allInterceptors = this.__$interceptors;
if (allInterceptors == null) {
allInterceptors = {};
this.__$interceptors = allInterceptors;
}
var interceptMethods = ((require("../utils/Type")).isCallback(interceptor))
? __interceptCallback
: __interceptObject;
var itfs = itfCstr.prototype.$interfaces;
for (var i in itfs) {
if (itfs.hasOwnProperty(i)) {
var interceptedMethods = interceptMethods(itfs[i].interfaceDefinition.$interface, interceptor, allInterceptors[i]);
allInterceptors[i] = interceptedMethods;
}
}
} | [
"function",
"(",
"itf",
",",
"interceptor",
")",
"{",
"var",
"itfCstr",
"=",
"this",
".",
"$interfaces",
"[",
"itf",
"]",
";",
"if",
"(",
"!",
"itfCstr",
")",
"{",
"this",
".",
"$logError",
"(",
"this",
".",
"INTERFACE_NOT_SUPPORTED",
",",
"[",
"itf",
",",
"this",
".",
"$classpath",
"]",
")",
";",
"return",
";",
"}",
"var",
"allInterceptors",
"=",
"this",
".",
"__$interceptors",
";",
"if",
"(",
"allInterceptors",
"==",
"null",
")",
"{",
"allInterceptors",
"=",
"{",
"}",
";",
"this",
".",
"__$interceptors",
"=",
"allInterceptors",
";",
"}",
"var",
"interceptMethods",
"=",
"(",
"(",
"require",
"(",
"\"../utils/Type\"",
")",
")",
".",
"isCallback",
"(",
"interceptor",
")",
")",
"?",
"__interceptCallback",
":",
"__interceptObject",
";",
"var",
"itfs",
"=",
"itfCstr",
".",
"prototype",
".",
"$interfaces",
";",
"for",
"(",
"var",
"i",
"in",
"itfs",
")",
"{",
"if",
"(",
"itfs",
".",
"hasOwnProperty",
"(",
"i",
")",
")",
"{",
"var",
"interceptedMethods",
"=",
"interceptMethods",
"(",
"itfs",
"[",
"i",
"]",
".",
"interfaceDefinition",
".",
"$interface",
",",
"interceptor",
",",
"allInterceptors",
"[",
"i",
"]",
")",
";",
"allInterceptors",
"[",
"i",
"]",
"=",
"interceptedMethods",
";",
"}",
"}",
"}"
]
| Add an interceptor callback on an interface specified by its classpath.
@param {String} itf [mandatory] interface which will be intercepted
@param {Object|aria.core.CfgBeans:Callback} interceptor either a callback or an object/class which will
receive notifications | [
"Add",
"an",
"interceptor",
"callback",
"on",
"an",
"interface",
"specified",
"by",
"its",
"classpath",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/JsObject.js#L512-L535 | train |
|
ariatemplates/ariatemplates | src/aria/core/JsObject.js | function (itf, scope, fn) {
var itfCstr = this.$interfaces[itf];
var allInterceptors = this.__$interceptors;
if (!itfCstr || !allInterceptors) {
return;
}
var itfs = itfCstr.prototype.$interfaces;
// also remove the interceptor on all base interfaces of the interface
for (var i in itfs) {
if (itfs.hasOwnProperty(i)) {
__removeInterceptorCallback(allInterceptors, i, scope, fn);
}
}
} | javascript | function (itf, scope, fn) {
var itfCstr = this.$interfaces[itf];
var allInterceptors = this.__$interceptors;
if (!itfCstr || !allInterceptors) {
return;
}
var itfs = itfCstr.prototype.$interfaces;
// also remove the interceptor on all base interfaces of the interface
for (var i in itfs) {
if (itfs.hasOwnProperty(i)) {
__removeInterceptorCallback(allInterceptors, i, scope, fn);
}
}
} | [
"function",
"(",
"itf",
",",
"scope",
",",
"fn",
")",
"{",
"var",
"itfCstr",
"=",
"this",
".",
"$interfaces",
"[",
"itf",
"]",
";",
"var",
"allInterceptors",
"=",
"this",
".",
"__$interceptors",
";",
"if",
"(",
"!",
"itfCstr",
"||",
"!",
"allInterceptors",
")",
"{",
"return",
";",
"}",
"var",
"itfs",
"=",
"itfCstr",
".",
"prototype",
".",
"$interfaces",
";",
"for",
"(",
"var",
"i",
"in",
"itfs",
")",
"{",
"if",
"(",
"itfs",
".",
"hasOwnProperty",
"(",
"i",
")",
")",
"{",
"__removeInterceptorCallback",
"(",
"allInterceptors",
",",
"i",
",",
"scope",
",",
"fn",
")",
";",
"}",
"}",
"}"
]
| Remove interceptor callbacks or interceptor objects on an interface.
@param {String} itf [mandatory] interface which is intercepted
@param {Object} scope [optional] scope of the callbacks/objects to remove
@param {Function} fn [optional] function in the callbacks to remove | [
"Remove",
"interceptor",
"callbacks",
"or",
"interceptor",
"objects",
"on",
"an",
"interface",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/JsObject.js#L543-L556 | train |
|
ariatemplates/ariatemplates | src/aria/core/JsObject.js | function (interfaceName, methodName, args, asyncCbParam) {
var interceptors;
if (this.__$interceptors == null || this.__$interceptors[interfaceName] == null
|| (interceptors = this.__$interceptors[interfaceName][methodName]) == null) {
// no interceptor for that interface: call the method directly:
return this[methodName].apply(this, args);
}
return __callWrapper.call(this, args, {
interceptors : interceptors,
nbInterceptors : interceptors.length,
method : methodName,
asyncCbParam : asyncCbParam
}, 0);
} | javascript | function (interfaceName, methodName, args, asyncCbParam) {
var interceptors;
if (this.__$interceptors == null || this.__$interceptors[interfaceName] == null
|| (interceptors = this.__$interceptors[interfaceName][methodName]) == null) {
// no interceptor for that interface: call the method directly:
return this[methodName].apply(this, args);
}
return __callWrapper.call(this, args, {
interceptors : interceptors,
nbInterceptors : interceptors.length,
method : methodName,
asyncCbParam : asyncCbParam
}, 0);
} | [
"function",
"(",
"interfaceName",
",",
"methodName",
",",
"args",
",",
"asyncCbParam",
")",
"{",
"var",
"interceptors",
";",
"if",
"(",
"this",
".",
"__$interceptors",
"==",
"null",
"||",
"this",
".",
"__$interceptors",
"[",
"interfaceName",
"]",
"==",
"null",
"||",
"(",
"interceptors",
"=",
"this",
".",
"__$interceptors",
"[",
"interfaceName",
"]",
"[",
"methodName",
"]",
")",
"==",
"null",
")",
"{",
"return",
"this",
"[",
"methodName",
"]",
".",
"apply",
"(",
"this",
",",
"args",
")",
";",
"}",
"return",
"__callWrapper",
".",
"call",
"(",
"this",
",",
"args",
",",
"{",
"interceptors",
":",
"interceptors",
",",
"nbInterceptors",
":",
"interceptors",
".",
"length",
",",
"method",
":",
"methodName",
",",
"asyncCbParam",
":",
"asyncCbParam",
"}",
",",
"0",
")",
";",
"}"
]
| Call a method from this class, taking into account any registered interceptor.
@param {String} interfaceName Classpath of the interface in which the method is declared (directly). The
actual interface from which this method is called maybe an interface which extends this one.
@param {String} methodName Method name.
@param {Array} args Array of parameters to send to the method.
@param {Number} asyncCbParam [optional] if the method is asynchronous, must contain the index in args of
the callback parameter. Should be null if the method is not asynchronous. | [
"Call",
"a",
"method",
"from",
"this",
"class",
"taking",
"into",
"account",
"any",
"registered",
"interceptor",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/JsObject.js#L567-L580 | train |
|
ariatemplates/ariatemplates | src/aria/core/JsObject.js | function (lstCfg, itfWrap) {
if (this._listeners == null) {
return;
}
var defaultScope = (lstCfg.scope) ? lstCfg.scope : null;
var lsn;
for (var evt in lstCfg) {
if (!lstCfg.hasOwnProperty(evt)) {
continue;
}
if (evt == 'scope') {
continue;
}
if (this._listeners[evt]) {
var lsnRm = lstCfg[evt];
if (typeof(lsnRm) == 'function') {
if (defaultScope == null) {
this.$logError(this.MISSING_SCOPE, evt);
continue;
}
__removeCallback(this._listeners, evt, defaultScope, lsnRm, itfWrap);
} else {
if (lsnRm.scope == null) {
lsnRm.scope = defaultScope;
}
if (lsnRm.scope == null) {
this.$logError(this.MISSING_SCOPE, evt);
continue;
}
__removeCallback(this._listeners, evt, lsnRm.scope, lsnRm.fn, itfWrap, lsnRm.firstOnly);
}
}
}
defaultScope = lsn = lsnRm = null;
} | javascript | function (lstCfg, itfWrap) {
if (this._listeners == null) {
return;
}
var defaultScope = (lstCfg.scope) ? lstCfg.scope : null;
var lsn;
for (var evt in lstCfg) {
if (!lstCfg.hasOwnProperty(evt)) {
continue;
}
if (evt == 'scope') {
continue;
}
if (this._listeners[evt]) {
var lsnRm = lstCfg[evt];
if (typeof(lsnRm) == 'function') {
if (defaultScope == null) {
this.$logError(this.MISSING_SCOPE, evt);
continue;
}
__removeCallback(this._listeners, evt, defaultScope, lsnRm, itfWrap);
} else {
if (lsnRm.scope == null) {
lsnRm.scope = defaultScope;
}
if (lsnRm.scope == null) {
this.$logError(this.MISSING_SCOPE, evt);
continue;
}
__removeCallback(this._listeners, evt, lsnRm.scope, lsnRm.fn, itfWrap, lsnRm.firstOnly);
}
}
}
defaultScope = lsn = lsnRm = null;
} | [
"function",
"(",
"lstCfg",
",",
"itfWrap",
")",
"{",
"if",
"(",
"this",
".",
"_listeners",
"==",
"null",
")",
"{",
"return",
";",
"}",
"var",
"defaultScope",
"=",
"(",
"lstCfg",
".",
"scope",
")",
"?",
"lstCfg",
".",
"scope",
":",
"null",
";",
"var",
"lsn",
";",
"for",
"(",
"var",
"evt",
"in",
"lstCfg",
")",
"{",
"if",
"(",
"!",
"lstCfg",
".",
"hasOwnProperty",
"(",
"evt",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"evt",
"==",
"'scope'",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"this",
".",
"_listeners",
"[",
"evt",
"]",
")",
"{",
"var",
"lsnRm",
"=",
"lstCfg",
"[",
"evt",
"]",
";",
"if",
"(",
"typeof",
"(",
"lsnRm",
")",
"==",
"'function'",
")",
"{",
"if",
"(",
"defaultScope",
"==",
"null",
")",
"{",
"this",
".",
"$logError",
"(",
"this",
".",
"MISSING_SCOPE",
",",
"evt",
")",
";",
"continue",
";",
"}",
"__removeCallback",
"(",
"this",
".",
"_listeners",
",",
"evt",
",",
"defaultScope",
",",
"lsnRm",
",",
"itfWrap",
")",
";",
"}",
"else",
"{",
"if",
"(",
"lsnRm",
".",
"scope",
"==",
"null",
")",
"{",
"lsnRm",
".",
"scope",
"=",
"defaultScope",
";",
"}",
"if",
"(",
"lsnRm",
".",
"scope",
"==",
"null",
")",
"{",
"this",
".",
"$logError",
"(",
"this",
".",
"MISSING_SCOPE",
",",
"evt",
")",
";",
"continue",
";",
"}",
"__removeCallback",
"(",
"this",
".",
"_listeners",
",",
"evt",
",",
"lsnRm",
".",
"scope",
",",
"lsnRm",
".",
"fn",
",",
"itfWrap",
",",
"lsnRm",
".",
"firstOnly",
")",
";",
"}",
"}",
"}",
"defaultScope",
"=",
"lsn",
"=",
"lsnRm",
"=",
"null",
";",
"}"
]
| Remove a listener from the listener list
@param {Object} lstCfg list of events to disconnect - same as for addListener(), except that scope is
mandatory Note: if fn is not provided, all listeners associated to the scope will be removed
@param {Object} itfWrap | [
"Remove",
"a",
"listener",
"from",
"the",
"listener",
"list"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/JsObject.js#L698-L733 | train |
|
ariatemplates/ariatemplates | src/aria/core/JsObject.js | function (scope, itfWrap) {
if (this._listeners == null) {
return;
}
// We must check itfWrap == null, so that it is not possible to unregister all the events of an object
// from its interface, if they have not been registered through that interface
if (scope == null && itfWrap == null) {
// remove all events
for (var evt in this._listeners) {
if (!this._listeners.hasOwnProperty(evt)) {
continue;
}
this._listeners[evt] = null; // remove array
delete this._listeners[evt];
}
} else {
// note that here, scope can be null (if itfWrap != null) we need to filter all events in this case
for (var evt in this._listeners) {
if (!this._listeners.hasOwnProperty(evt)) {
continue;
}
__removeCallback(this._listeners, evt, scope, null, itfWrap);
}
}
evt = null;
} | javascript | function (scope, itfWrap) {
if (this._listeners == null) {
return;
}
// We must check itfWrap == null, so that it is not possible to unregister all the events of an object
// from its interface, if they have not been registered through that interface
if (scope == null && itfWrap == null) {
// remove all events
for (var evt in this._listeners) {
if (!this._listeners.hasOwnProperty(evt)) {
continue;
}
this._listeners[evt] = null; // remove array
delete this._listeners[evt];
}
} else {
// note that here, scope can be null (if itfWrap != null) we need to filter all events in this case
for (var evt in this._listeners) {
if (!this._listeners.hasOwnProperty(evt)) {
continue;
}
__removeCallback(this._listeners, evt, scope, null, itfWrap);
}
}
evt = null;
} | [
"function",
"(",
"scope",
",",
"itfWrap",
")",
"{",
"if",
"(",
"this",
".",
"_listeners",
"==",
"null",
")",
"{",
"return",
";",
"}",
"if",
"(",
"scope",
"==",
"null",
"&&",
"itfWrap",
"==",
"null",
")",
"{",
"for",
"(",
"var",
"evt",
"in",
"this",
".",
"_listeners",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_listeners",
".",
"hasOwnProperty",
"(",
"evt",
")",
")",
"{",
"continue",
";",
"}",
"this",
".",
"_listeners",
"[",
"evt",
"]",
"=",
"null",
";",
"delete",
"this",
".",
"_listeners",
"[",
"evt",
"]",
";",
"}",
"}",
"else",
"{",
"for",
"(",
"var",
"evt",
"in",
"this",
".",
"_listeners",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_listeners",
".",
"hasOwnProperty",
"(",
"evt",
")",
")",
"{",
"continue",
";",
"}",
"__removeCallback",
"(",
"this",
".",
"_listeners",
",",
"evt",
",",
"scope",
",",
"null",
",",
"itfWrap",
")",
";",
"}",
"}",
"evt",
"=",
"null",
";",
"}"
]
| Remove all listeners associated to a given scope - if no scope is provided all listeneres will be removed
@param {Object} scope the scope of the listeners to remove
@param {Object} itfWrap | [
"Remove",
"all",
"listeners",
"associated",
"to",
"a",
"given",
"scope",
"-",
"if",
"no",
"scope",
"is",
"provided",
"all",
"listeneres",
"will",
"be",
"removed"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/JsObject.js#L740-L765 | train |
|
ariatemplates/ariatemplates | src/aria/jsunit/RobotPhantomJS.js | function (position, callback) {
var lastPosition = this._lastMousePosition;
lastPosition.x = position.x;
lastPosition.y = position.y;
this._sendEvent('mousemove', position.x, position.y);
this._callCallback(callback);
} | javascript | function (position, callback) {
var lastPosition = this._lastMousePosition;
lastPosition.x = position.x;
lastPosition.y = position.y;
this._sendEvent('mousemove', position.x, position.y);
this._callCallback(callback);
} | [
"function",
"(",
"position",
",",
"callback",
")",
"{",
"var",
"lastPosition",
"=",
"this",
".",
"_lastMousePosition",
";",
"lastPosition",
".",
"x",
"=",
"position",
".",
"x",
";",
"lastPosition",
".",
"y",
"=",
"position",
".",
"y",
";",
"this",
".",
"_sendEvent",
"(",
"'mousemove'",
",",
"position",
".",
"x",
",",
"position",
".",
"y",
")",
";",
"this",
".",
"_callCallback",
"(",
"callback",
")",
";",
"}"
]
| Sets the mouse position, with PhantomJS screen coordinates.
@param {Object} position position where to set the mouse (given as an object with x and y properties, in
PhantomJS screen coordinates)
@param {aria.core.CfgBeans:Callback} callback | [
"Sets",
"the",
"mouse",
"position",
"with",
"PhantomJS",
"screen",
"coordinates",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/jsunit/RobotPhantomJS.js#L178-L184 | train |
|
ariatemplates/ariatemplates | src/aria/jsunit/RobotPhantomJS.js | function (from, to, duration, cb) {
var translatedFromPosition = this._translateCoordinates(from);
var translatedToPosition = this._translateCoordinates(to);
this.smoothAbsoluteMouseMove(translatedFromPosition, translatedToPosition, duration, cb);
} | javascript | function (from, to, duration, cb) {
var translatedFromPosition = this._translateCoordinates(from);
var translatedToPosition = this._translateCoordinates(to);
this.smoothAbsoluteMouseMove(translatedFromPosition, translatedToPosition, duration, cb);
} | [
"function",
"(",
"from",
",",
"to",
",",
"duration",
",",
"cb",
")",
"{",
"var",
"translatedFromPosition",
"=",
"this",
".",
"_translateCoordinates",
"(",
"from",
")",
";",
"var",
"translatedToPosition",
"=",
"this",
".",
"_translateCoordinates",
"(",
"to",
")",
";",
"this",
".",
"smoothAbsoluteMouseMove",
"(",
"translatedFromPosition",
",",
"translatedToPosition",
",",
"duration",
",",
"cb",
")",
";",
"}"
]
| Smoothly moves the mouse from one position to another, with coordinates relative to the viewport.
@param {Object} fromPosition initial position where to set the mouse first (given as an object with x and y
properties, in viewport coordinates)
@param {Object} toPosition final position of mouse (given as an object with x and y properties, in viewport
coordinates)
@param {Number} duration Time in ms for the mouse move.
@param {aria.core.CfgBeans:Callback} callback | [
"Smoothly",
"moves",
"the",
"mouse",
"from",
"one",
"position",
"to",
"another",
"with",
"coordinates",
"relative",
"to",
"the",
"viewport",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/jsunit/RobotPhantomJS.js#L195-L199 | train |
|
ariatemplates/ariatemplates | src/aria/jsunit/RobotPhantomJS.js | function (from, to, duration, cb) {
this.absoluteMouseMove(from, {
fn : this._stepSmoothAbsoluteMouseMove,
scope : this,
resIndex : -1,
args : {
from : from,
to : to,
duration : duration,
cb : cb,
endTime : new Date().getTime() + duration
}
});
} | javascript | function (from, to, duration, cb) {
this.absoluteMouseMove(from, {
fn : this._stepSmoothAbsoluteMouseMove,
scope : this,
resIndex : -1,
args : {
from : from,
to : to,
duration : duration,
cb : cb,
endTime : new Date().getTime() + duration
}
});
} | [
"function",
"(",
"from",
",",
"to",
",",
"duration",
",",
"cb",
")",
"{",
"this",
".",
"absoluteMouseMove",
"(",
"from",
",",
"{",
"fn",
":",
"this",
".",
"_stepSmoothAbsoluteMouseMove",
",",
"scope",
":",
"this",
",",
"resIndex",
":",
"-",
"1",
",",
"args",
":",
"{",
"from",
":",
"from",
",",
"to",
":",
"to",
",",
"duration",
":",
"duration",
",",
"cb",
":",
"cb",
",",
"endTime",
":",
"new",
"Date",
"(",
")",
".",
"getTime",
"(",
")",
"+",
"duration",
"}",
"}",
")",
";",
"}"
]
| Smoothly moves the mouse from one position to another, with PhantomJS screen coordinates.
@param {Object} fromPosition initial position where to set the mouse first (given as an object with x and y
properties, in PhantomJS screen coordinates)
@param {Object} toPosition final position of mouse (given as an object with x and y properties, in PhantomJS
screen coordinates)
@param {Number} duration Time in ms for the mouse move.
@param {aria.core.CfgBeans:Callback} callback | [
"Smoothly",
"moves",
"the",
"mouse",
"from",
"one",
"position",
"to",
"another",
"with",
"PhantomJS",
"screen",
"coordinates",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/jsunit/RobotPhantomJS.js#L210-L223 | train |
|
ariatemplates/ariatemplates | src/aria/jsunit/RobotPhantomJS.js | function (button, cb) {
var lastPosition = this._lastMousePosition;
this._sendEvent('mousedown', lastPosition.x, lastPosition.y, this.BUTTONS[button]);
this._callCallback(cb);
} | javascript | function (button, cb) {
var lastPosition = this._lastMousePosition;
this._sendEvent('mousedown', lastPosition.x, lastPosition.y, this.BUTTONS[button]);
this._callCallback(cb);
} | [
"function",
"(",
"button",
",",
"cb",
")",
"{",
"var",
"lastPosition",
"=",
"this",
".",
"_lastMousePosition",
";",
"this",
".",
"_sendEvent",
"(",
"'mousedown'",
",",
"lastPosition",
".",
"x",
",",
"lastPosition",
".",
"y",
",",
"this",
".",
"BUTTONS",
"[",
"button",
"]",
")",
";",
"this",
".",
"_callCallback",
"(",
"cb",
")",
";",
"}"
]
| Simulates a mouse button press.
@param {Number} button Button to be pressed (should be the value of aria.jsunit.Robot.BUTTONx_MASK, with x
replaced by 1, 2 or 3).
@param {aria.core.CfgBeans:Callback} callback | [
"Simulates",
"a",
"mouse",
"button",
"press",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/jsunit/RobotPhantomJS.js#L254-L258 | train |
|
ariatemplates/ariatemplates | src/aria/jsunit/RobotPhantomJS.js | function (keyCode, cb) {
if (keyCode == this.KEYS.VK_SHIFT) {
this._keyShift = true;
}
if (keyCode == this.KEYS.VK_CTRL) {
this._keyCtrl = true;
}
if (typeof keyCode == "string" && this._keyShift) {
keyCode = keyCode.toUpperCase();
}
if (keyCode == this.KEYS.VK_ALT) {
this._keyAlt = true;
}
this._sendEvent('keydown', keyCode, null, null, this._getModifier());
this._callCallback(cb);
} | javascript | function (keyCode, cb) {
if (keyCode == this.KEYS.VK_SHIFT) {
this._keyShift = true;
}
if (keyCode == this.KEYS.VK_CTRL) {
this._keyCtrl = true;
}
if (typeof keyCode == "string" && this._keyShift) {
keyCode = keyCode.toUpperCase();
}
if (keyCode == this.KEYS.VK_ALT) {
this._keyAlt = true;
}
this._sendEvent('keydown', keyCode, null, null, this._getModifier());
this._callCallback(cb);
} | [
"function",
"(",
"keyCode",
",",
"cb",
")",
"{",
"if",
"(",
"keyCode",
"==",
"this",
".",
"KEYS",
".",
"VK_SHIFT",
")",
"{",
"this",
".",
"_keyShift",
"=",
"true",
";",
"}",
"if",
"(",
"keyCode",
"==",
"this",
".",
"KEYS",
".",
"VK_CTRL",
")",
"{",
"this",
".",
"_keyCtrl",
"=",
"true",
";",
"}",
"if",
"(",
"typeof",
"keyCode",
"==",
"\"string\"",
"&&",
"this",
".",
"_keyShift",
")",
"{",
"keyCode",
"=",
"keyCode",
".",
"toUpperCase",
"(",
")",
";",
"}",
"if",
"(",
"keyCode",
"==",
"this",
".",
"KEYS",
".",
"VK_ALT",
")",
"{",
"this",
".",
"_keyAlt",
"=",
"true",
";",
"}",
"this",
".",
"_sendEvent",
"(",
"'keydown'",
",",
"keyCode",
",",
"null",
",",
"null",
",",
"this",
".",
"_getModifier",
"(",
")",
")",
";",
"this",
".",
"_callCallback",
"(",
"cb",
")",
";",
"}"
]
| Simulates a keyboard key press.
@param {MultiTypes} key specifies which key should be pressed. It can be any value among the ones in the KEYS
property.
@param {aria.core.CfgBeans:Callback} callback | [
"Simulates",
"a",
"keyboard",
"key",
"press",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/jsunit/RobotPhantomJS.js#L285-L300 | train |
|
ariatemplates/ariatemplates | src/aria/widgets/frames/FixedHeightFrame.js | function (skipBorder, icons) {
var hasBorder = (skipBorder === false);
if (skipBorder == "dependsOnIcon") {
hasBorder = (icons.length === 0);
}
return hasBorder;
} | javascript | function (skipBorder, icons) {
var hasBorder = (skipBorder === false);
if (skipBorder == "dependsOnIcon") {
hasBorder = (icons.length === 0);
}
return hasBorder;
} | [
"function",
"(",
"skipBorder",
",",
"icons",
")",
"{",
"var",
"hasBorder",
"=",
"(",
"skipBorder",
"===",
"false",
")",
";",
"if",
"(",
"skipBorder",
"==",
"\"dependsOnIcon\"",
")",
"{",
"hasBorder",
"=",
"(",
"icons",
".",
"length",
"===",
"0",
")",
";",
"}",
"return",
"hasBorder",
";",
"}"
]
| Checks for any border in left or right.
@protected
@param {String} border
@param {Array} Icons
@return {Boolean} | [
"Checks",
"for",
"any",
"border",
"in",
"left",
"or",
"right",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/frames/FixedHeightFrame.js#L180-L186 | train |
|
ariatemplates/ariatemplates | src/aria/utils/Orientation.js | function () {
var window = Aria.$window;
if (typeof(window.orientation) != "undefined") { // check if browser support orientation change
this.screenOrientation = window.orientation;
this.isPortrait = this.__isPortrait();
// start listening native event orinetationchange.
ariaUtilsEvent.addListener(window, "orientationchange", {
fn : this._onOrientationChange,
scope : this
});
}
} | javascript | function () {
var window = Aria.$window;
if (typeof(window.orientation) != "undefined") { // check if browser support orientation change
this.screenOrientation = window.orientation;
this.isPortrait = this.__isPortrait();
// start listening native event orinetationchange.
ariaUtilsEvent.addListener(window, "orientationchange", {
fn : this._onOrientationChange,
scope : this
});
}
} | [
"function",
"(",
")",
"{",
"var",
"window",
"=",
"Aria",
".",
"$window",
";",
"if",
"(",
"typeof",
"(",
"window",
".",
"orientation",
")",
"!=",
"\"undefined\"",
")",
"{",
"this",
".",
"screenOrientation",
"=",
"window",
".",
"orientation",
";",
"this",
".",
"isPortrait",
"=",
"this",
".",
"__isPortrait",
"(",
")",
";",
"ariaUtilsEvent",
".",
"addListener",
"(",
"window",
",",
"\"orientationchange\"",
",",
"{",
"fn",
":",
"this",
".",
"_onOrientationChange",
",",
"scope",
":",
"this",
"}",
")",
";",
"}",
"}"
]
| Adding a listener while initializing Orientation to listen to the native orientationchange event. | [
"Adding",
"a",
"listener",
"while",
"initializing",
"Orientation",
"to",
"listen",
"to",
"the",
"native",
"orientationchange",
"event",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Orientation.js#L35-L47 | train |
|
ariatemplates/ariatemplates | src/aria/utils/Orientation.js | function () {
this.screenOrientation = Aria.$window.orientation;
this.isPortrait = this.__isPortrait();
// raise event "change" to notify about orientation change along with properties for current orientation
this.$raiseEvent({
name : "change",
screenOrientation : this.screenOrientation,
isPortrait : this.isPortrait
});
} | javascript | function () {
this.screenOrientation = Aria.$window.orientation;
this.isPortrait = this.__isPortrait();
// raise event "change" to notify about orientation change along with properties for current orientation
this.$raiseEvent({
name : "change",
screenOrientation : this.screenOrientation,
isPortrait : this.isPortrait
});
} | [
"function",
"(",
")",
"{",
"this",
".",
"screenOrientation",
"=",
"Aria",
".",
"$window",
".",
"orientation",
";",
"this",
".",
"isPortrait",
"=",
"this",
".",
"__isPortrait",
"(",
")",
";",
"this",
".",
"$raiseEvent",
"(",
"{",
"name",
":",
"\"change\"",
",",
"screenOrientation",
":",
"this",
".",
"screenOrientation",
",",
"isPortrait",
":",
"this",
".",
"isPortrait",
"}",
")",
";",
"}"
]
| Callback executed after orientation of the device is changed. This raises a wrapper event for the native
event orientationchange and provides properties screenOrientation which is exact value of window.orientation
and additional variable isPortrait to tell if device orientation is portrait
@protected | [
"Callback",
"executed",
"after",
"orientation",
"of",
"the",
"device",
"is",
"changed",
".",
"This",
"raises",
"a",
"wrapper",
"event",
"for",
"the",
"native",
"event",
"orientationchange",
"and",
"provides",
"properties",
"screenOrientation",
"which",
"is",
"exact",
"value",
"of",
"window",
".",
"orientation",
"and",
"additional",
"variable",
"isPortrait",
"to",
"tell",
"if",
"device",
"orientation",
"is",
"portrait"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Orientation.js#L63-L72 | train |
|
ariatemplates/ariatemplates | src/aria/touch/widgets/DoubleSlider.js | function () {
var value, binding = this._binding;
if (!binding) {
return;
}
value = binding.inside[binding.to];
if (ariaUtilsType.isArray(value)) {
// Constrain values to be between 0 and 1 and the first to be smaller
this.value[0] = Math.max(0, Math.min(value[0], value[1], 1));
this.value[1] = Math.min(1, Math.max(value[0], value[1], 0));
}
ariaUtilsJson.setValue(binding.inside, binding.to, this.value, this._bindingCallback);
} | javascript | function () {
var value, binding = this._binding;
if (!binding) {
return;
}
value = binding.inside[binding.to];
if (ariaUtilsType.isArray(value)) {
// Constrain values to be between 0 and 1 and the first to be smaller
this.value[0] = Math.max(0, Math.min(value[0], value[1], 1));
this.value[1] = Math.min(1, Math.max(value[0], value[1], 0));
}
ariaUtilsJson.setValue(binding.inside, binding.to, this.value, this._bindingCallback);
} | [
"function",
"(",
")",
"{",
"var",
"value",
",",
"binding",
"=",
"this",
".",
"_binding",
";",
"if",
"(",
"!",
"binding",
")",
"{",
"return",
";",
"}",
"value",
"=",
"binding",
".",
"inside",
"[",
"binding",
".",
"to",
"]",
";",
"if",
"(",
"ariaUtilsType",
".",
"isArray",
"(",
"value",
")",
")",
"{",
"this",
".",
"value",
"[",
"0",
"]",
"=",
"Math",
".",
"max",
"(",
"0",
",",
"Math",
".",
"min",
"(",
"value",
"[",
"0",
"]",
",",
"value",
"[",
"1",
"]",
",",
"1",
")",
")",
";",
"this",
".",
"value",
"[",
"1",
"]",
"=",
"Math",
".",
"min",
"(",
"1",
",",
"Math",
".",
"max",
"(",
"value",
"[",
"0",
"]",
",",
"value",
"[",
"1",
"]",
",",
"0",
")",
")",
";",
"}",
"ariaUtilsJson",
".",
"setValue",
"(",
"binding",
".",
"inside",
",",
"binding",
".",
"to",
",",
"this",
".",
"value",
",",
"this",
".",
"_bindingCallback",
")",
";",
"}"
]
| Read the bound value in the data model, ensure it is defined, between 0 and 1, and assign the value property.
@protected | [
"Read",
"the",
"bound",
"value",
"in",
"the",
"data",
"model",
"ensure",
"it",
"is",
"defined",
"between",
"0",
"and",
"1",
"and",
"assign",
"the",
"value",
"property",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/touch/widgets/DoubleSlider.js#L297-L309 | train |
|
ariatemplates/ariatemplates | src/aria/touch/widgets/DoubleSlider.js | function () {
var first = Math.max(0, Math.min(this.value[0], this.value[1], 1));
var second = Math.min(1, Math.max(this.value[0], this.value[1], 0));
this._savedX1 = Math.floor(first * this._railWidth);
this._savedX2 = Math.ceil(second * this._railWidth + this._firstWidth);
} | javascript | function () {
var first = Math.max(0, Math.min(this.value[0], this.value[1], 1));
var second = Math.min(1, Math.max(this.value[0], this.value[1], 0));
this._savedX1 = Math.floor(first * this._railWidth);
this._savedX2 = Math.ceil(second * this._railWidth + this._firstWidth);
} | [
"function",
"(",
")",
"{",
"var",
"first",
"=",
"Math",
".",
"max",
"(",
"0",
",",
"Math",
".",
"min",
"(",
"this",
".",
"value",
"[",
"0",
"]",
",",
"this",
".",
"value",
"[",
"1",
"]",
",",
"1",
")",
")",
";",
"var",
"second",
"=",
"Math",
".",
"min",
"(",
"1",
",",
"Math",
".",
"max",
"(",
"this",
".",
"value",
"[",
"0",
"]",
",",
"this",
".",
"value",
"[",
"1",
"]",
",",
"0",
")",
")",
";",
"this",
".",
"_savedX1",
"=",
"Math",
".",
"floor",
"(",
"first",
"*",
"this",
".",
"_railWidth",
")",
";",
"this",
".",
"_savedX2",
"=",
"Math",
".",
"ceil",
"(",
"second",
"*",
"this",
".",
"_railWidth",
"+",
"this",
".",
"_firstWidth",
")",
";",
"}"
]
| Set the left position of the two thumbs without knowing if they are correct. The first thumb is aligned on
the left, while the second on the right. | [
"Set",
"the",
"left",
"position",
"of",
"the",
"two",
"thumbs",
"without",
"knowing",
"if",
"they",
"are",
"correct",
".",
"The",
"first",
"thumb",
"is",
"aligned",
"on",
"the",
"left",
"while",
"the",
"second",
"on",
"the",
"right",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/touch/widgets/DoubleSlider.js#L315-L320 | train |
|
ariatemplates/ariatemplates | src/aria/touch/widgets/DoubleSlider.js | function () {
var left = this._savedX1 + this._firstWidth / 2;
var widthHighlight = this._savedX2 + (this._secondWidth / 2) - left;
this._highlight.style.left = left + "px";
this._highlight.style.width = widthHighlight + "px";
} | javascript | function () {
var left = this._savedX1 + this._firstWidth / 2;
var widthHighlight = this._savedX2 + (this._secondWidth / 2) - left;
this._highlight.style.left = left + "px";
this._highlight.style.width = widthHighlight + "px";
} | [
"function",
"(",
")",
"{",
"var",
"left",
"=",
"this",
".",
"_savedX1",
"+",
"this",
".",
"_firstWidth",
"/",
"2",
";",
"var",
"widthHighlight",
"=",
"this",
".",
"_savedX2",
"+",
"(",
"this",
".",
"_secondWidth",
"/",
"2",
")",
"-",
"left",
";",
"this",
".",
"_highlight",
".",
"style",
".",
"left",
"=",
"left",
"+",
"\"px\"",
";",
"this",
".",
"_highlight",
".",
"style",
".",
"width",
"=",
"widthHighlight",
"+",
"\"px\"",
";",
"}"
]
| Update the width and position of the highlight between two thumbs.
@protected | [
"Update",
"the",
"width",
"and",
"position",
"of",
"the",
"highlight",
"between",
"two",
"thumbs",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/touch/widgets/DoubleSlider.js#L337-L342 | train |
|
ariatemplates/ariatemplates | src/aria/touch/widgets/DoubleSlider.js | function (evt) {
this._oldValue = [this.value[0], this.value[1]];
// Just store the initial position of the element to compute the move later
this._initialDrag = evt.src.posX;
this._initialSavedX = evt.src.id === this._firstDomId ? this._savedX1 : this._savedX2;
} | javascript | function (evt) {
this._oldValue = [this.value[0], this.value[1]];
// Just store the initial position of the element to compute the move later
this._initialDrag = evt.src.posX;
this._initialSavedX = evt.src.id === this._firstDomId ? this._savedX1 : this._savedX2;
} | [
"function",
"(",
"evt",
")",
"{",
"this",
".",
"_oldValue",
"=",
"[",
"this",
".",
"value",
"[",
"0",
"]",
",",
"this",
".",
"value",
"[",
"1",
"]",
"]",
";",
"this",
".",
"_initialDrag",
"=",
"evt",
".",
"src",
".",
"posX",
";",
"this",
".",
"_initialSavedX",
"=",
"evt",
".",
"src",
".",
"id",
"===",
"this",
".",
"_firstDomId",
"?",
"this",
".",
"_savedX1",
":",
"this",
".",
"_savedX2",
";",
"}"
]
| Handle the beginning of a drag
@protected
@param {aria.DomEvent} evt | [
"Handle",
"the",
"beginning",
"of",
"a",
"drag"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/touch/widgets/DoubleSlider.js#L390-L395 | train |
|
ariatemplates/ariatemplates | src/aria/touch/widgets/DoubleSlider.js | function () {
var left = this._savedX1, right = this._savedX2;
var first = Math.max(left / this._railWidth, 0);
var second = Math.min((right - this._firstWidth) / this._railWidth, 1);
if (this.value[0] !== first || this.value[1] !== second) {
this.value = [first, second];
var binding = this._binding;
ariaUtilsJson.setValue(binding.inside, binding.to, this.value);
} else {
// Trying to go somewhere far, don't update value, but only the display
this._notifyDataChange();
}
return;
} | javascript | function () {
var left = this._savedX1, right = this._savedX2;
var first = Math.max(left / this._railWidth, 0);
var second = Math.min((right - this._firstWidth) / this._railWidth, 1);
if (this.value[0] !== first || this.value[1] !== second) {
this.value = [first, second];
var binding = this._binding;
ariaUtilsJson.setValue(binding.inside, binding.to, this.value);
} else {
// Trying to go somewhere far, don't update value, but only the display
this._notifyDataChange();
}
return;
} | [
"function",
"(",
")",
"{",
"var",
"left",
"=",
"this",
".",
"_savedX1",
",",
"right",
"=",
"this",
".",
"_savedX2",
";",
"var",
"first",
"=",
"Math",
".",
"max",
"(",
"left",
"/",
"this",
".",
"_railWidth",
",",
"0",
")",
";",
"var",
"second",
"=",
"Math",
".",
"min",
"(",
"(",
"right",
"-",
"this",
".",
"_firstWidth",
")",
"/",
"this",
".",
"_railWidth",
",",
"1",
")",
";",
"if",
"(",
"this",
".",
"value",
"[",
"0",
"]",
"!==",
"first",
"||",
"this",
".",
"value",
"[",
"1",
"]",
"!==",
"second",
")",
"{",
"this",
".",
"value",
"=",
"[",
"first",
",",
"second",
"]",
";",
"var",
"binding",
"=",
"this",
".",
"_binding",
";",
"ariaUtilsJson",
".",
"setValue",
"(",
"binding",
".",
"inside",
",",
"binding",
".",
"to",
",",
"this",
".",
"value",
")",
";",
"}",
"else",
"{",
"this",
".",
"_notifyDataChange",
"(",
")",
";",
"}",
"return",
";",
"}"
]
| Set the value of the slider in the data model given the left position of the thumbs.
@protected | [
"Set",
"the",
"value",
"of",
"the",
"slider",
"in",
"the",
"data",
"model",
"given",
"the",
"left",
"position",
"of",
"the",
"thumbs",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/touch/widgets/DoubleSlider.js#L453-L468 | train |
|
ariatemplates/ariatemplates | src/aria/utils/FrameATLoader.js | function (frame, cb, options) {
this.loadBootstrap({
fn : this._loadATInFrameCb1,
scope : this,
args : {
options : options || {},
frame : frame,
cb : cb
}
});
} | javascript | function (frame, cb, options) {
this.loadBootstrap({
fn : this._loadATInFrameCb1,
scope : this,
args : {
options : options || {},
frame : frame,
cb : cb
}
});
} | [
"function",
"(",
"frame",
",",
"cb",
",",
"options",
")",
"{",
"this",
".",
"loadBootstrap",
"(",
"{",
"fn",
":",
"this",
".",
"_loadATInFrameCb1",
",",
"scope",
":",
"this",
",",
"args",
":",
"{",
"options",
":",
"options",
"||",
"{",
"}",
",",
"frame",
":",
"frame",
",",
"cb",
":",
"cb",
"}",
"}",
")",
";",
"}"
]
| Load Aria Templates in the given frame and call the callback. This replaces the content of the frame.
@param {HTMLElement} frame frame
@param {aria.core.CfgBeans:Callback} cb callback. The first argument is an object containing success
information.
@param {Object} options The following options are supported:<ul>
<li>iframePageCss {String} CSS text to be injected in the frame. E.g. {iframePageCss : "body {font-family:Arial}"}</li>
<li>crossDomain {Boolean} when true, FrameATLoader works even when Aria Templates is loaded from a different domain (uses
document.write instead of loading a URL)</li>
<li>onBeforeLoadingAria {aria.core.CfgBeans:Callback} callback called just before loading Aria Templates in the frame</li>
<li>skipSkinCopy {Boolean} whether to skip the copy of the skin from the current page</li>
<li>keepLoadingIndicator {Boolean} whether to keep the loading indicator (DOM element with the "loadingIndicator" id) at
the end</li>
<li>extraScripts {Array of String} list of scripts to load in the page (inserted with the ScriptLoader at the end)</li>
</ul> | [
"Load",
"Aria",
"Templates",
"in",
"the",
"given",
"frame",
"and",
"call",
"the",
"callback",
".",
"This",
"replaces",
"the",
"content",
"of",
"the",
"frame",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/FrameATLoader.js#L139-L149 | train |
|
ariatemplates/ariatemplates | src/aria/utils/FrameATLoader.js | function (pattern) {
var scripts = Aria.$frameworkWindow.document.getElementsByTagName("script");
for (var i = 0, l = scripts.length; i < l; i++) {
var script = scripts[i];
if (script.attributes && script.attributes["src"]) {
var src = script.attributes["src"].nodeValue;
if (pattern.exec(src)) {
return src;
}
}
}
this.$logError("Could not find the script corresponding to pattern: %1. Please set the aria.jsunit.FrameATLoader.frameworkHref property manually.");
return null;
} | javascript | function (pattern) {
var scripts = Aria.$frameworkWindow.document.getElementsByTagName("script");
for (var i = 0, l = scripts.length; i < l; i++) {
var script = scripts[i];
if (script.attributes && script.attributes["src"]) {
var src = script.attributes["src"].nodeValue;
if (pattern.exec(src)) {
return src;
}
}
}
this.$logError("Could not find the script corresponding to pattern: %1. Please set the aria.jsunit.FrameATLoader.frameworkHref property manually.");
return null;
} | [
"function",
"(",
"pattern",
")",
"{",
"var",
"scripts",
"=",
"Aria",
".",
"$frameworkWindow",
".",
"document",
".",
"getElementsByTagName",
"(",
"\"script\"",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"scripts",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"var",
"script",
"=",
"scripts",
"[",
"i",
"]",
";",
"if",
"(",
"script",
".",
"attributes",
"&&",
"script",
".",
"attributes",
"[",
"\"src\"",
"]",
")",
"{",
"var",
"src",
"=",
"script",
".",
"attributes",
"[",
"\"src\"",
"]",
".",
"nodeValue",
";",
"if",
"(",
"pattern",
".",
"exec",
"(",
"src",
")",
")",
"{",
"return",
"src",
";",
"}",
"}",
"}",
"this",
".",
"$logError",
"(",
"\"Could not find the script corresponding to pattern: %1. Please set the aria.jsunit.FrameATLoader.frameworkHref property manually.\"",
")",
";",
"return",
"null",
";",
"}"
]
| Loop over script tags in the current document and return the address of the script which matches the pattern.
@param {RegExp} pattern
@return {String} | [
"Loop",
"over",
"script",
"tags",
"in",
"the",
"current",
"document",
"and",
"return",
"the",
"address",
"of",
"the",
"script",
"which",
"matches",
"the",
"pattern",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/FrameATLoader.js#L321-L334 | train |
|
ariatemplates/ariatemplates | src/aria/pageEngine/pageProviders/BasePageProvider.js | function (res, cb) {
if (res.downloadFailed) {
this.__onFailure(res, cb.args);
} else {
var fileContent = ariaCoreDownloadMgr.getFileContent(res.logicalPaths[0]);
var responseJSON = ariaUtilsJson.load(fileContent);
if (responseJSON) {
this.$callback(cb, responseJSON);
} else {
this.__onFailure(res, cb.args);
}
}
} | javascript | function (res, cb) {
if (res.downloadFailed) {
this.__onFailure(res, cb.args);
} else {
var fileContent = ariaCoreDownloadMgr.getFileContent(res.logicalPaths[0]);
var responseJSON = ariaUtilsJson.load(fileContent);
if (responseJSON) {
this.$callback(cb, responseJSON);
} else {
this.__onFailure(res, cb.args);
}
}
} | [
"function",
"(",
"res",
",",
"cb",
")",
"{",
"if",
"(",
"res",
".",
"downloadFailed",
")",
"{",
"this",
".",
"__onFailure",
"(",
"res",
",",
"cb",
".",
"args",
")",
";",
"}",
"else",
"{",
"var",
"fileContent",
"=",
"ariaCoreDownloadMgr",
".",
"getFileContent",
"(",
"res",
".",
"logicalPaths",
"[",
"0",
"]",
")",
";",
"var",
"responseJSON",
"=",
"ariaUtilsJson",
".",
"load",
"(",
"fileContent",
")",
";",
"if",
"(",
"responseJSON",
")",
"{",
"this",
".",
"$callback",
"(",
"cb",
",",
"responseJSON",
")",
";",
"}",
"else",
"{",
"this",
".",
"__onFailure",
"(",
"res",
",",
"cb",
".",
"args",
")",
";",
"}",
"}",
"}"
]
| Retrieve the file content after it has been downloaded and parses it to turn it into a JSON object
@param {Object} res Response received from the loadFile method of aria.core.DownloadManager
@param {aria.core.CfgBeans:Callback} cb Callback to be called after the response has been parsed | [
"Retrieve",
"the",
"file",
"content",
"after",
"it",
"has",
"been",
"downloaded",
"and",
"parses",
"it",
"to",
"turn",
"it",
"into",
"a",
"JSON",
"object"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/pageEngine/pageProviders/BasePageProvider.js#L147-L159 | train |
|
ariatemplates/ariatemplates | src/aria/pageEngine/pageProviders/BasePageProvider.js | function (pageRequest) {
var map = this.__urlMap.urlToPageId, pageId = pageRequest.pageId, url = pageRequest.url;
if (pageId) {
return pageId;
}
if (url) {
var returnUrl = map[url] || map[url + "/"] || map[url.replace(/\/$/, "")];
if (returnUrl) {
return returnUrl;
}
}
return this.__config.homePageId;
} | javascript | function (pageRequest) {
var map = this.__urlMap.urlToPageId, pageId = pageRequest.pageId, url = pageRequest.url;
if (pageId) {
return pageId;
}
if (url) {
var returnUrl = map[url] || map[url + "/"] || map[url.replace(/\/$/, "")];
if (returnUrl) {
return returnUrl;
}
}
return this.__config.homePageId;
} | [
"function",
"(",
"pageRequest",
")",
"{",
"var",
"map",
"=",
"this",
".",
"__urlMap",
".",
"urlToPageId",
",",
"pageId",
"=",
"pageRequest",
".",
"pageId",
",",
"url",
"=",
"pageRequest",
".",
"url",
";",
"if",
"(",
"pageId",
")",
"{",
"return",
"pageId",
";",
"}",
"if",
"(",
"url",
")",
"{",
"var",
"returnUrl",
"=",
"map",
"[",
"url",
"]",
"||",
"map",
"[",
"url",
"+",
"\"/\"",
"]",
"||",
"map",
"[",
"url",
".",
"replace",
"(",
"/",
"\\/$",
"/",
",",
"\"\"",
")",
"]",
";",
"if",
"(",
"returnUrl",
")",
"{",
"return",
"returnUrl",
";",
"}",
"}",
"return",
"this",
".",
"__config",
".",
"homePageId",
";",
"}"
]
| Retrieve the pageId based on the pageRequest information, as well as the url map. As a default, the
homePageId is returned
@param {aria.pageEngine.CfgBeans:PageRequest} pageRequest
@return {String} the pageId
@private | [
"Retrieve",
"the",
"pageId",
"based",
"on",
"the",
"pageRequest",
"information",
"as",
"well",
"as",
"the",
"url",
"map",
".",
"As",
"a",
"default",
"the",
"homePageId",
"is",
"returned"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/pageEngine/pageProviders/BasePageProvider.js#L244-L256 | train |
|
ariatemplates/ariatemplates | src/aria/core/AppEnvironment.js | function (cfg, callback, update) {
update = !!update;
var keys = ariaUtilsObject.keys(cfg);
if (update) {
ariaUtilsJson.inject(cfg, this.applicationSettings, true);
} else {
if (keys.length === 0) {
// reset stored application settings
this.applicationSettings = {};
keys = null;
} else {
for (var i = 0; i < keys.length; i++) {
var keyName = keys[i];
this.applicationSettings[keyName] = cfg[keyName];
}
}
}
var evt = {
name : "changingEnvironment",
changedProperties : keys,
asyncCalls : 1
};
evt.callback = {
fn : function () {
evt.asyncCalls--;
if (evt.asyncCalls <= 0) {
evt.callback.fn = null;
evt = null;
keys = null;
this.$callback(callback);
}
},
scope : this
};
this.$raiseEvent(evt);
this.$raiseEvent({
name : "environmentChanged",
changedProperties : keys
});
this.$callback(evt.callback);
} | javascript | function (cfg, callback, update) {
update = !!update;
var keys = ariaUtilsObject.keys(cfg);
if (update) {
ariaUtilsJson.inject(cfg, this.applicationSettings, true);
} else {
if (keys.length === 0) {
// reset stored application settings
this.applicationSettings = {};
keys = null;
} else {
for (var i = 0; i < keys.length; i++) {
var keyName = keys[i];
this.applicationSettings[keyName] = cfg[keyName];
}
}
}
var evt = {
name : "changingEnvironment",
changedProperties : keys,
asyncCalls : 1
};
evt.callback = {
fn : function () {
evt.asyncCalls--;
if (evt.asyncCalls <= 0) {
evt.callback.fn = null;
evt = null;
keys = null;
this.$callback(callback);
}
},
scope : this
};
this.$raiseEvent(evt);
this.$raiseEvent({
name : "environmentChanged",
changedProperties : keys
});
this.$callback(evt.callback);
} | [
"function",
"(",
"cfg",
",",
"callback",
",",
"update",
")",
"{",
"update",
"=",
"!",
"!",
"update",
";",
"var",
"keys",
"=",
"ariaUtilsObject",
".",
"keys",
"(",
"cfg",
")",
";",
"if",
"(",
"update",
")",
"{",
"ariaUtilsJson",
".",
"inject",
"(",
"cfg",
",",
"this",
".",
"applicationSettings",
",",
"true",
")",
";",
"}",
"else",
"{",
"if",
"(",
"keys",
".",
"length",
"===",
"0",
")",
"{",
"this",
".",
"applicationSettings",
"=",
"{",
"}",
";",
"keys",
"=",
"null",
";",
"}",
"else",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"keyName",
"=",
"keys",
"[",
"i",
"]",
";",
"this",
".",
"applicationSettings",
"[",
"keyName",
"]",
"=",
"cfg",
"[",
"keyName",
"]",
";",
"}",
"}",
"}",
"var",
"evt",
"=",
"{",
"name",
":",
"\"changingEnvironment\"",
",",
"changedProperties",
":",
"keys",
",",
"asyncCalls",
":",
"1",
"}",
";",
"evt",
".",
"callback",
"=",
"{",
"fn",
":",
"function",
"(",
")",
"{",
"evt",
".",
"asyncCalls",
"--",
";",
"if",
"(",
"evt",
".",
"asyncCalls",
"<=",
"0",
")",
"{",
"evt",
".",
"callback",
".",
"fn",
"=",
"null",
";",
"evt",
"=",
"null",
";",
"keys",
"=",
"null",
";",
"this",
".",
"$callback",
"(",
"callback",
")",
";",
"}",
"}",
",",
"scope",
":",
"this",
"}",
";",
"this",
".",
"$raiseEvent",
"(",
"evt",
")",
";",
"this",
".",
"$raiseEvent",
"(",
"{",
"name",
":",
"\"environmentChanged\"",
",",
"changedProperties",
":",
"keys",
"}",
")",
";",
"this",
".",
"$callback",
"(",
"evt",
".",
"callback",
")",
";",
"}"
]
| Stores the application variables. Please refer to documentation for parameter types.
@public
@param {Object} cfg Configuration object
@param {aria.core.CfgBeans:Callback} cb Method to be called after the setting is done
@param {Boolean} update flag to update existing application settings, when false will overwrite existing with
new settings. | [
"Stores",
"the",
"application",
"variables",
".",
"Please",
"refer",
"to",
"documentation",
"for",
"parameter",
"types",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/AppEnvironment.js#L58-L98 | train |
|
ariatemplates/ariatemplates | src/aria/widgets/Text.js | function (textContent) {
// String cast
if (textContent !== null) {
textContent = '' + textContent;
} else {
textContent = '';
}
var dom = this.getDom();
if (dom) {
var stringUtils = ariaUtilsString;
this.textContent = textContent;
dom.style.display = "inline-block";
dom.style.overflow = "hidden";
dom.style.whiteSpace = "nowrap";
dom.style.verticalAlign = "top";
var textWidth, ellipsisElement = ariaUtilsDom.getDomElementChild(dom, 0);
if (!ellipsisElement) {
dom.innerHTML = '<span class="createdEllipisElement">' + stringUtils.escapeHTML(this.textContent)
+ '</span>';
ellipsisElement = ariaUtilsDom.getDomElementChild(dom, 0);
}
if (this._cfg.width > 0) {
textWidth = this._cfg.width;
dom.style.width = this._cfg.width + "px";
this._ellipsis = new ariaUtilsEllipsis(ellipsisElement, textWidth, this._cfg.ellipsisLocation, this._cfg.ellipsis, this._context, this._cfg.ellipsisEndStyle);
if (!this._ellipsis.ellipsesNeeded) {
// No ellipsis was done so remove the <span> and put the full text into the text widget itself
dom.removeChild(ellipsisElement);
dom.innerHTML = stringUtils.escapeHTML(textContent);
}
}
}
} | javascript | function (textContent) {
// String cast
if (textContent !== null) {
textContent = '' + textContent;
} else {
textContent = '';
}
var dom = this.getDom();
if (dom) {
var stringUtils = ariaUtilsString;
this.textContent = textContent;
dom.style.display = "inline-block";
dom.style.overflow = "hidden";
dom.style.whiteSpace = "nowrap";
dom.style.verticalAlign = "top";
var textWidth, ellipsisElement = ariaUtilsDom.getDomElementChild(dom, 0);
if (!ellipsisElement) {
dom.innerHTML = '<span class="createdEllipisElement">' + stringUtils.escapeHTML(this.textContent)
+ '</span>';
ellipsisElement = ariaUtilsDom.getDomElementChild(dom, 0);
}
if (this._cfg.width > 0) {
textWidth = this._cfg.width;
dom.style.width = this._cfg.width + "px";
this._ellipsis = new ariaUtilsEllipsis(ellipsisElement, textWidth, this._cfg.ellipsisLocation, this._cfg.ellipsis, this._context, this._cfg.ellipsisEndStyle);
if (!this._ellipsis.ellipsesNeeded) {
// No ellipsis was done so remove the <span> and put the full text into the text widget itself
dom.removeChild(ellipsisElement);
dom.innerHTML = stringUtils.escapeHTML(textContent);
}
}
}
} | [
"function",
"(",
"textContent",
")",
"{",
"if",
"(",
"textContent",
"!==",
"null",
")",
"{",
"textContent",
"=",
"''",
"+",
"textContent",
";",
"}",
"else",
"{",
"textContent",
"=",
"''",
";",
"}",
"var",
"dom",
"=",
"this",
".",
"getDom",
"(",
")",
";",
"if",
"(",
"dom",
")",
"{",
"var",
"stringUtils",
"=",
"ariaUtilsString",
";",
"this",
".",
"textContent",
"=",
"textContent",
";",
"dom",
".",
"style",
".",
"display",
"=",
"\"inline-block\"",
";",
"dom",
".",
"style",
".",
"overflow",
"=",
"\"hidden\"",
";",
"dom",
".",
"style",
".",
"whiteSpace",
"=",
"\"nowrap\"",
";",
"dom",
".",
"style",
".",
"verticalAlign",
"=",
"\"top\"",
";",
"var",
"textWidth",
",",
"ellipsisElement",
"=",
"ariaUtilsDom",
".",
"getDomElementChild",
"(",
"dom",
",",
"0",
")",
";",
"if",
"(",
"!",
"ellipsisElement",
")",
"{",
"dom",
".",
"innerHTML",
"=",
"'<span class=\"createdEllipisElement\">'",
"+",
"stringUtils",
".",
"escapeHTML",
"(",
"this",
".",
"textContent",
")",
"+",
"'</span>'",
";",
"ellipsisElement",
"=",
"ariaUtilsDom",
".",
"getDomElementChild",
"(",
"dom",
",",
"0",
")",
";",
"}",
"if",
"(",
"this",
".",
"_cfg",
".",
"width",
">",
"0",
")",
"{",
"textWidth",
"=",
"this",
".",
"_cfg",
".",
"width",
";",
"dom",
".",
"style",
".",
"width",
"=",
"this",
".",
"_cfg",
".",
"width",
"+",
"\"px\"",
";",
"this",
".",
"_ellipsis",
"=",
"new",
"ariaUtilsEllipsis",
"(",
"ellipsisElement",
",",
"textWidth",
",",
"this",
".",
"_cfg",
".",
"ellipsisLocation",
",",
"this",
".",
"_cfg",
".",
"ellipsis",
",",
"this",
".",
"_context",
",",
"this",
".",
"_cfg",
".",
"ellipsisEndStyle",
")",
";",
"if",
"(",
"!",
"this",
".",
"_ellipsis",
".",
"ellipsesNeeded",
")",
"{",
"dom",
".",
"removeChild",
"(",
"ellipsisElement",
")",
";",
"dom",
".",
"innerHTML",
"=",
"stringUtils",
".",
"escapeHTML",
"(",
"textContent",
")",
";",
"}",
"}",
"}",
"}"
]
| Check if the width of text is too long and if so, ellipse it
@param {String} textContent the text to be ellipsed
@private | [
"Check",
"if",
"the",
"width",
"of",
"text",
"is",
"too",
"long",
"and",
"if",
"so",
"ellipse",
"it"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/Text.js#L114-L152 | train |
|
ariatemplates/ariatemplates | src/aria/map/MapManager.js | function (providerName, provider) {
if (providers[providerName]) {
this.$logError(this.DUPLICATED_PROVIDER, providerName);
} else {
if (ariaUtilsType.isObject(provider)) {
if (this._isValidProvider(provider)) {
providerInstances[providerName] = provider;
providers[providerName] = provider;
} else {
this.$logError(this.INVALID_PROVIDER, providerName);
}
} else {
providers[providerName] = provider;
}
}
} | javascript | function (providerName, provider) {
if (providers[providerName]) {
this.$logError(this.DUPLICATED_PROVIDER, providerName);
} else {
if (ariaUtilsType.isObject(provider)) {
if (this._isValidProvider(provider)) {
providerInstances[providerName] = provider;
providers[providerName] = provider;
} else {
this.$logError(this.INVALID_PROVIDER, providerName);
}
} else {
providers[providerName] = provider;
}
}
} | [
"function",
"(",
"providerName",
",",
"provider",
")",
"{",
"if",
"(",
"providers",
"[",
"providerName",
"]",
")",
"{",
"this",
".",
"$logError",
"(",
"this",
".",
"DUPLICATED_PROVIDER",
",",
"providerName",
")",
";",
"}",
"else",
"{",
"if",
"(",
"ariaUtilsType",
".",
"isObject",
"(",
"provider",
")",
")",
"{",
"if",
"(",
"this",
".",
"_isValidProvider",
"(",
"provider",
")",
")",
"{",
"providerInstances",
"[",
"providerName",
"]",
"=",
"provider",
";",
"providers",
"[",
"providerName",
"]",
"=",
"provider",
";",
"}",
"else",
"{",
"this",
".",
"$logError",
"(",
"this",
".",
"INVALID_PROVIDER",
",",
"providerName",
")",
";",
"}",
"}",
"else",
"{",
"providers",
"[",
"providerName",
"]",
"=",
"provider",
";",
"}",
"}",
"}"
]
| Add a provider by specifying the class that should be used to load dependencies and create maps instances
@param {String} providerName
@param {String|Object} provider classpath or Object with methods "load", "getMap" and "disposeMap" | [
"Add",
"a",
"provider",
"by",
"specifying",
"the",
"class",
"that",
"should",
"be",
"used",
"to",
"load",
"dependencies",
"and",
"create",
"maps",
"instances"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/map/MapManager.js#L221-L236 | train |
|
ariatemplates/ariatemplates | src/aria/map/MapManager.js | function (providerName) {
this.destroyAllMaps(providerName);
delete providers[providerName];
if (providerInstancesToDispose[providerName]) {
providerInstancesToDispose[providerName].$dispose();
delete providerInstancesToDispose[providerName];
}
delete providerInstances[providerName];
} | javascript | function (providerName) {
this.destroyAllMaps(providerName);
delete providers[providerName];
if (providerInstancesToDispose[providerName]) {
providerInstancesToDispose[providerName].$dispose();
delete providerInstancesToDispose[providerName];
}
delete providerInstances[providerName];
} | [
"function",
"(",
"providerName",
")",
"{",
"this",
".",
"destroyAllMaps",
"(",
"providerName",
")",
";",
"delete",
"providers",
"[",
"providerName",
"]",
";",
"if",
"(",
"providerInstancesToDispose",
"[",
"providerName",
"]",
")",
"{",
"providerInstancesToDispose",
"[",
"providerName",
"]",
".",
"$dispose",
"(",
")",
";",
"delete",
"providerInstancesToDispose",
"[",
"providerName",
"]",
";",
"}",
"delete",
"providerInstances",
"[",
"providerName",
"]",
";",
"}"
]
| Remove a provider by specifying the shortcut for the provider. It destroys all the maps created with that
provider
@param {String} provider | [
"Remove",
"a",
"provider",
"by",
"specifying",
"the",
"shortcut",
"for",
"the",
"provider",
".",
"It",
"destroys",
"all",
"the",
"maps",
"created",
"with",
"that",
"provider"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/map/MapManager.js#L243-L251 | train |
|
ariatemplates/ariatemplates | src/aria/map/MapManager.js | function (provider) {
var valid = true, methods = ["load", "getMap", "disposeMap"];
for (var i = 0; i < methods.length; i++) {
valid = valid && provider[methods[i]] && ariaUtilsType.isFunction(provider[methods[i]]);
}
return valid;
} | javascript | function (provider) {
var valid = true, methods = ["load", "getMap", "disposeMap"];
for (var i = 0; i < methods.length; i++) {
valid = valid && provider[methods[i]] && ariaUtilsType.isFunction(provider[methods[i]]);
}
return valid;
} | [
"function",
"(",
"provider",
")",
"{",
"var",
"valid",
"=",
"true",
",",
"methods",
"=",
"[",
"\"load\"",
",",
"\"getMap\"",
",",
"\"disposeMap\"",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"methods",
".",
"length",
";",
"i",
"++",
")",
"{",
"valid",
"=",
"valid",
"&&",
"provider",
"[",
"methods",
"[",
"i",
"]",
"]",
"&&",
"ariaUtilsType",
".",
"isFunction",
"(",
"provider",
"[",
"methods",
"[",
"i",
"]",
"]",
")",
";",
"}",
"return",
"valid",
";",
"}"
]
| Check that the given provider has the right methods
@param {Object} provider
@return {Boolean} | [
"Check",
"that",
"the",
"given",
"provider",
"has",
"the",
"right",
"methods"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/map/MapManager.js#L342-L348 | train |
|
ariatemplates/ariatemplates | src/aria/map/MapManager.js | function (res, cfg) {
var providerInstance = providerInstances[cfg.provider];
providerInstance.load({
fn : this._retrieveMapInstance,
scope : this,
args : cfg
});
} | javascript | function (res, cfg) {
var providerInstance = providerInstances[cfg.provider];
providerInstance.load({
fn : this._retrieveMapInstance,
scope : this,
args : cfg
});
} | [
"function",
"(",
"res",
",",
"cfg",
")",
"{",
"var",
"providerInstance",
"=",
"providerInstances",
"[",
"cfg",
".",
"provider",
"]",
";",
"providerInstance",
".",
"load",
"(",
"{",
"fn",
":",
"this",
".",
"_retrieveMapInstance",
",",
"scope",
":",
"this",
",",
"args",
":",
"cfg",
"}",
")",
";",
"}"
]
| Load the provider dependencies. Called after loading the provider class
@param {Object} res
@param {aria.map.CfgBeans:CreateMapCfg} cfg
@private | [
"Load",
"the",
"provider",
"dependencies",
".",
"Called",
"after",
"loading",
"the",
"provider",
"class"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/map/MapManager.js#L356-L363 | train |
|
ariatemplates/ariatemplates | src/aria/widgets/controllers/AutoCompleteController.js | function () {
var freeTxtStatus = false, dataListContent = this._dataModel.listContent;
for (var i = 0, len = dataListContent.length; i < len; i += 1) {
if (this._dataModel.text === dataListContent[i].value.label) {
freeTxtStatus = true;
break;
}
}
return freeTxtStatus;
} | javascript | function () {
var freeTxtStatus = false, dataListContent = this._dataModel.listContent;
for (var i = 0, len = dataListContent.length; i < len; i += 1) {
if (this._dataModel.text === dataListContent[i].value.label) {
freeTxtStatus = true;
break;
}
}
return freeTxtStatus;
} | [
"function",
"(",
")",
"{",
"var",
"freeTxtStatus",
"=",
"false",
",",
"dataListContent",
"=",
"this",
".",
"_dataModel",
".",
"listContent",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"dataListContent",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"+=",
"1",
")",
"{",
"if",
"(",
"this",
".",
"_dataModel",
".",
"text",
"===",
"dataListContent",
"[",
"i",
"]",
".",
"value",
".",
"label",
")",
"{",
"freeTxtStatus",
"=",
"true",
";",
"break",
";",
"}",
"}",
"return",
"freeTxtStatus",
";",
"}"
]
| Checks the displayed text is available in the returned suggestion, this will apply only in case of
freetext is set to false
@param {Object} value
@return {Boolean} | [
"Checks",
"the",
"displayed",
"text",
"is",
"available",
"in",
"the",
"returned",
"suggestion",
"this",
"will",
"apply",
"only",
"in",
"case",
"of",
"freetext",
"is",
"set",
"to",
"false"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/controllers/AutoCompleteController.js#L201-L210 | train |
|
ariatemplates/ariatemplates | src/aria/widgets/controllers/AutoCompleteController.js | function (value) {
var report = new ariaWidgetsControllersReportsDropDownControllerReport(), dataModel = this._dataModel;
if (value == null) {
// can be null either because it bound to null or because a request is in progress
dataModel.text = (this._pendingRequestNb > 0 && dataModel.text) ? dataModel.text : "";
dataModel.value = null;
report.ok = true;
} else if (value && !typeUtil.isString(value)) {
if (ariaCoreJsonValidator.check(value, this._resourcesHandler.SUGGESTION_BEAN)) {
var text = this._getLabelFromSuggestion(value);
dataModel.text = text;
dataModel.value = value;
report.ok = true;
} else {
dataModel.value = null;
report.ok = false;
this.$logError("Value does not match definition for this autocomplete: "
+ this._resourcesHandler.SUGGESTION_BEAN, [], value);
}
} else {
if (typeUtil.isString(value)) {
dataModel.text = value;
}
if (!this.freeText) {
report.ok = false;
dataModel.value = null;
} else {
report.ok = true;
dataModel.value = value;
}
}
report.value = dataModel.value;
report.text = dataModel.text;
return report;
} | javascript | function (value) {
var report = new ariaWidgetsControllersReportsDropDownControllerReport(), dataModel = this._dataModel;
if (value == null) {
// can be null either because it bound to null or because a request is in progress
dataModel.text = (this._pendingRequestNb > 0 && dataModel.text) ? dataModel.text : "";
dataModel.value = null;
report.ok = true;
} else if (value && !typeUtil.isString(value)) {
if (ariaCoreJsonValidator.check(value, this._resourcesHandler.SUGGESTION_BEAN)) {
var text = this._getLabelFromSuggestion(value);
dataModel.text = text;
dataModel.value = value;
report.ok = true;
} else {
dataModel.value = null;
report.ok = false;
this.$logError("Value does not match definition for this autocomplete: "
+ this._resourcesHandler.SUGGESTION_BEAN, [], value);
}
} else {
if (typeUtil.isString(value)) {
dataModel.text = value;
}
if (!this.freeText) {
report.ok = false;
dataModel.value = null;
} else {
report.ok = true;
dataModel.value = value;
}
}
report.value = dataModel.value;
report.text = dataModel.text;
return report;
} | [
"function",
"(",
"value",
")",
"{",
"var",
"report",
"=",
"new",
"ariaWidgetsControllersReportsDropDownControllerReport",
"(",
")",
",",
"dataModel",
"=",
"this",
".",
"_dataModel",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"dataModel",
".",
"text",
"=",
"(",
"this",
".",
"_pendingRequestNb",
">",
"0",
"&&",
"dataModel",
".",
"text",
")",
"?",
"dataModel",
".",
"text",
":",
"\"\"",
";",
"dataModel",
".",
"value",
"=",
"null",
";",
"report",
".",
"ok",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"value",
"&&",
"!",
"typeUtil",
".",
"isString",
"(",
"value",
")",
")",
"{",
"if",
"(",
"ariaCoreJsonValidator",
".",
"check",
"(",
"value",
",",
"this",
".",
"_resourcesHandler",
".",
"SUGGESTION_BEAN",
")",
")",
"{",
"var",
"text",
"=",
"this",
".",
"_getLabelFromSuggestion",
"(",
"value",
")",
";",
"dataModel",
".",
"text",
"=",
"text",
";",
"dataModel",
".",
"value",
"=",
"value",
";",
"report",
".",
"ok",
"=",
"true",
";",
"}",
"else",
"{",
"dataModel",
".",
"value",
"=",
"null",
";",
"report",
".",
"ok",
"=",
"false",
";",
"this",
".",
"$logError",
"(",
"\"Value does not match definition for this autocomplete: \"",
"+",
"this",
".",
"_resourcesHandler",
".",
"SUGGESTION_BEAN",
",",
"[",
"]",
",",
"value",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"typeUtil",
".",
"isString",
"(",
"value",
")",
")",
"{",
"dataModel",
".",
"text",
"=",
"value",
";",
"}",
"if",
"(",
"!",
"this",
".",
"freeText",
")",
"{",
"report",
".",
"ok",
"=",
"false",
";",
"dataModel",
".",
"value",
"=",
"null",
";",
"}",
"else",
"{",
"report",
".",
"ok",
"=",
"true",
";",
"dataModel",
".",
"value",
"=",
"value",
";",
"}",
"}",
"report",
".",
"value",
"=",
"dataModel",
".",
"value",
";",
"report",
".",
"text",
"=",
"dataModel",
".",
"text",
";",
"return",
"report",
";",
"}"
]
| OVERRIDE Verify a given value
@param {Object} value
@return {aria.widgets.controllers.reports.DropDownControllerReport}
@override | [
"OVERRIDE",
"Verify",
"a",
"given",
"value"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/controllers/AutoCompleteController.js#L218-L252 | train |
|
ariatemplates/ariatemplates | src/aria/widgets/controllers/AutoCompleteController.js | function (suggestions, textEntry) {
var matchValueIndex = -1, suggestion;
for (var index = 0, len = suggestions.length, label, ariaLabel; index < len; index += 1) {
suggestion = suggestions[index];
// if it's the first exact match, store it
if (matchValueIndex == -1) {
if (suggestion.exactMatch) {
matchValueIndex = index;
}
}
label = this._getLabelFromSuggestion(suggestion);
ariaLabel = this.waiSuggestionAriaLabelGetter ? this.waiSuggestionAriaLabelGetter({
value: suggestion,
index: index,
total: len
}) : null;
var tmp = {
entry : textEntry,
label : label,
ariaLabel : ariaLabel,
value : suggestion
};
suggestions[index] = tmp;
}
return this.preselect === "none" ? -1 : matchValueIndex;
} | javascript | function (suggestions, textEntry) {
var matchValueIndex = -1, suggestion;
for (var index = 0, len = suggestions.length, label, ariaLabel; index < len; index += 1) {
suggestion = suggestions[index];
// if it's the first exact match, store it
if (matchValueIndex == -1) {
if (suggestion.exactMatch) {
matchValueIndex = index;
}
}
label = this._getLabelFromSuggestion(suggestion);
ariaLabel = this.waiSuggestionAriaLabelGetter ? this.waiSuggestionAriaLabelGetter({
value: suggestion,
index: index,
total: len
}) : null;
var tmp = {
entry : textEntry,
label : label,
ariaLabel : ariaLabel,
value : suggestion
};
suggestions[index] = tmp;
}
return this.preselect === "none" ? -1 : matchValueIndex;
} | [
"function",
"(",
"suggestions",
",",
"textEntry",
")",
"{",
"var",
"matchValueIndex",
"=",
"-",
"1",
",",
"suggestion",
";",
"for",
"(",
"var",
"index",
"=",
"0",
",",
"len",
"=",
"suggestions",
".",
"length",
",",
"label",
",",
"ariaLabel",
";",
"index",
"<",
"len",
";",
"index",
"+=",
"1",
")",
"{",
"suggestion",
"=",
"suggestions",
"[",
"index",
"]",
";",
"if",
"(",
"matchValueIndex",
"==",
"-",
"1",
")",
"{",
"if",
"(",
"suggestion",
".",
"exactMatch",
")",
"{",
"matchValueIndex",
"=",
"index",
";",
"}",
"}",
"label",
"=",
"this",
".",
"_getLabelFromSuggestion",
"(",
"suggestion",
")",
";",
"ariaLabel",
"=",
"this",
".",
"waiSuggestionAriaLabelGetter",
"?",
"this",
".",
"waiSuggestionAriaLabelGetter",
"(",
"{",
"value",
":",
"suggestion",
",",
"index",
":",
"index",
",",
"total",
":",
"len",
"}",
")",
":",
"null",
";",
"var",
"tmp",
"=",
"{",
"entry",
":",
"textEntry",
",",
"label",
":",
"label",
",",
"ariaLabel",
":",
"ariaLabel",
",",
"value",
":",
"suggestion",
"}",
";",
"suggestions",
"[",
"index",
"]",
"=",
"tmp",
";",
"}",
"return",
"this",
".",
"preselect",
"===",
"\"none\"",
"?",
"-",
"1",
":",
"matchValueIndex",
";",
"}"
]
| reformat the suggestions to be compatible with the list widget and search for perfect match
@protected
@param {Array} suggestions
@param {String} textEntry
@return {Number} index of the first exact match, or -1 | [
"reformat",
"the",
"suggestions",
"to",
"be",
"compatible",
"with",
"the",
"list",
"widget",
"and",
"search",
"for",
"perfect",
"match"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/controllers/AutoCompleteController.js#L420-L445 | train |
|
ariatemplates/ariatemplates | src/aria/widgets/controllers/AutoCompleteController.js | function (config, event) {
return (event.altKey == !!config.alt) && (event.shiftKey == !!config.shift)
&& (event.ctrlKey == !!config.ctrl);
} | javascript | function (config, event) {
return (event.altKey == !!config.alt) && (event.shiftKey == !!config.shift)
&& (event.ctrlKey == !!config.ctrl);
} | [
"function",
"(",
"config",
",",
"event",
")",
"{",
"return",
"(",
"event",
".",
"altKey",
"==",
"!",
"!",
"config",
".",
"alt",
")",
"&&",
"(",
"event",
".",
"shiftKey",
"==",
"!",
"!",
"config",
".",
"shift",
")",
"&&",
"(",
"event",
".",
"ctrlKey",
"==",
"!",
"!",
"config",
".",
"ctrl",
")",
";",
"}"
]
| Validates an event against a configuration
@param {Object} config
@param {aria.DomEvent} event
@protected | [
"Validates",
"an",
"event",
"against",
"a",
"configuration"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/controllers/AutoCompleteController.js#L517-L520 | train |
|
ariatemplates/ariatemplates | src/aria/widgets/controllers/AutoCompleteController.js | function (event) {
var specialKey = false, keyCode = event.keyCode;
for (var index = 0, keyMap; index < this.selectionKeys.length; index++) {
keyMap = this.selectionKeys[index];
if (this._validateModifiers(keyMap, event)) {
// case real key defined. For eg: 65 for a
if (ariaUtilsType.isNumber(keyMap.key)) {
if (keyMap.key === keyCode) {
specialKey = true;
break;
}
} else if (typeof(keyMap.key) !== "undefined"
&& event["KC_" + keyMap.key.toUpperCase()] == keyCode) {
specialKey = true;
break;
} else if (typeof(keyMap.key) !== "undefined"
&& String.fromCharCode(event.charCode) == keyMap.key) {
specialKey = true;
break;
}
}
}
return specialKey;
} | javascript | function (event) {
var specialKey = false, keyCode = event.keyCode;
for (var index = 0, keyMap; index < this.selectionKeys.length; index++) {
keyMap = this.selectionKeys[index];
if (this._validateModifiers(keyMap, event)) {
// case real key defined. For eg: 65 for a
if (ariaUtilsType.isNumber(keyMap.key)) {
if (keyMap.key === keyCode) {
specialKey = true;
break;
}
} else if (typeof(keyMap.key) !== "undefined"
&& event["KC_" + keyMap.key.toUpperCase()] == keyCode) {
specialKey = true;
break;
} else if (typeof(keyMap.key) !== "undefined"
&& String.fromCharCode(event.charCode) == keyMap.key) {
specialKey = true;
break;
}
}
}
return specialKey;
} | [
"function",
"(",
"event",
")",
"{",
"var",
"specialKey",
"=",
"false",
",",
"keyCode",
"=",
"event",
".",
"keyCode",
";",
"for",
"(",
"var",
"index",
"=",
"0",
",",
"keyMap",
";",
"index",
"<",
"this",
".",
"selectionKeys",
".",
"length",
";",
"index",
"++",
")",
"{",
"keyMap",
"=",
"this",
".",
"selectionKeys",
"[",
"index",
"]",
";",
"if",
"(",
"this",
".",
"_validateModifiers",
"(",
"keyMap",
",",
"event",
")",
")",
"{",
"if",
"(",
"ariaUtilsType",
".",
"isNumber",
"(",
"keyMap",
".",
"key",
")",
")",
"{",
"if",
"(",
"keyMap",
".",
"key",
"===",
"keyCode",
")",
"{",
"specialKey",
"=",
"true",
";",
"break",
";",
"}",
"}",
"else",
"if",
"(",
"typeof",
"(",
"keyMap",
".",
"key",
")",
"!==",
"\"undefined\"",
"&&",
"event",
"[",
"\"KC_\"",
"+",
"keyMap",
".",
"key",
".",
"toUpperCase",
"(",
")",
"]",
"==",
"keyCode",
")",
"{",
"specialKey",
"=",
"true",
";",
"break",
";",
"}",
"else",
"if",
"(",
"typeof",
"(",
"keyMap",
".",
"key",
")",
"!==",
"\"undefined\"",
"&&",
"String",
".",
"fromCharCode",
"(",
"event",
".",
"charCode",
")",
"==",
"keyMap",
".",
"key",
")",
"{",
"specialKey",
"=",
"true",
";",
"break",
";",
"}",
"}",
"}",
"return",
"specialKey",
";",
"}"
]
| Checking against special key combinations that trigger a selection of the item in the dropdown
@param {aria.DomEvent} event
@return {Boolean} Whether the event corresponds to a selection key | [
"Checking",
"against",
"special",
"key",
"combinations",
"that",
"trigger",
"a",
"selection",
"of",
"the",
"item",
"in",
"the",
"dropdown"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/controllers/AutoCompleteController.js#L527-L550 | train |
|
ariatemplates/ariatemplates | src/aria/utils/Ellipsis.js | function (el) {
var document = Aria.$window.document;
// Need to make sure the new element has the same exact styling applied as the original element so we use
// the same tag, class, style and append it to the same parent
var tempSizerEl = document.createElement(el.tagName);
tempSizerEl.className = el.className;
tempSizerEl.setAttribute("style", el.getAttribute("style"));
el.parentNode.appendChild(tempSizerEl);
// Now we need to make sure the element displays on one line and is not visible in the page
tempSizerEl.style.visibility = "hidden";
tempSizerEl.style.position = "absolute";
tempSizerEl.style.whiteSpace = "nowrap";
return tempSizerEl;
} | javascript | function (el) {
var document = Aria.$window.document;
// Need to make sure the new element has the same exact styling applied as the original element so we use
// the same tag, class, style and append it to the same parent
var tempSizerEl = document.createElement(el.tagName);
tempSizerEl.className = el.className;
tempSizerEl.setAttribute("style", el.getAttribute("style"));
el.parentNode.appendChild(tempSizerEl);
// Now we need to make sure the element displays on one line and is not visible in the page
tempSizerEl.style.visibility = "hidden";
tempSizerEl.style.position = "absolute";
tempSizerEl.style.whiteSpace = "nowrap";
return tempSizerEl;
} | [
"function",
"(",
"el",
")",
"{",
"var",
"document",
"=",
"Aria",
".",
"$window",
".",
"document",
";",
"var",
"tempSizerEl",
"=",
"document",
".",
"createElement",
"(",
"el",
".",
"tagName",
")",
";",
"tempSizerEl",
".",
"className",
"=",
"el",
".",
"className",
";",
"tempSizerEl",
".",
"setAttribute",
"(",
"\"style\"",
",",
"el",
".",
"getAttribute",
"(",
"\"style\"",
")",
")",
";",
"el",
".",
"parentNode",
".",
"appendChild",
"(",
"tempSizerEl",
")",
";",
"tempSizerEl",
".",
"style",
".",
"visibility",
"=",
"\"hidden\"",
";",
"tempSizerEl",
".",
"style",
".",
"position",
"=",
"\"absolute\"",
";",
"tempSizerEl",
".",
"style",
".",
"whiteSpace",
"=",
"\"nowrap\"",
";",
"return",
"tempSizerEl",
";",
"}"
]
| Create the temporary sizer element to be used internally to measure text
@param {HTMLElement} el The element that will be measured thanks to this sizer
@return {HTMLElement} The sizer element
@private | [
"Create",
"the",
"temporary",
"sizer",
"element",
"to",
"be",
"used",
"internally",
"to",
"measure",
"text"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Ellipsis.js#L231-L247 | train |
|
ariatemplates/ariatemplates | src/aria/utils/Ellipsis.js | function (relatedTarget) {
if (this.callbackID) {
ariaCoreTimer.cancelCallback(this.callbackID);
}
if (this._popup != null) {
if (!ariaUtilsDom.isAncestor(relatedTarget, this._popup.domElement)) {
if (this._popup) {
this._popup.closeOnMouseOut();
}
}
}
this.callbackID = null;
} | javascript | function (relatedTarget) {
if (this.callbackID) {
ariaCoreTimer.cancelCallback(this.callbackID);
}
if (this._popup != null) {
if (!ariaUtilsDom.isAncestor(relatedTarget, this._popup.domElement)) {
if (this._popup) {
this._popup.closeOnMouseOut();
}
}
}
this.callbackID = null;
} | [
"function",
"(",
"relatedTarget",
")",
"{",
"if",
"(",
"this",
".",
"callbackID",
")",
"{",
"ariaCoreTimer",
".",
"cancelCallback",
"(",
"this",
".",
"callbackID",
")",
";",
"}",
"if",
"(",
"this",
".",
"_popup",
"!=",
"null",
")",
"{",
"if",
"(",
"!",
"ariaUtilsDom",
".",
"isAncestor",
"(",
"relatedTarget",
",",
"this",
".",
"_popup",
".",
"domElement",
")",
")",
"{",
"if",
"(",
"this",
".",
"_popup",
")",
"{",
"this",
".",
"_popup",
".",
"closeOnMouseOut",
"(",
")",
";",
"}",
"}",
"}",
"this",
".",
"callbackID",
"=",
"null",
";",
"}"
]
| This hides the Full version of the ellipsised element
@param {Object} domEvt The click DOM event
@protected | [
"This",
"hides",
"the",
"Full",
"version",
"of",
"the",
"ellipsised",
"element"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Ellipsis.js#L332-L347 | train |
|
ariatemplates/ariatemplates | src/aria/utils/Function.js | function (fn, context) {
var args = [];
for (var i = 2; i < arguments.length; i++) {
args.push(arguments[i]);
}
return function () {
// need to make a copy each time
var finalArgs = args.slice(0);
// concat won't work, as arguments is a special array
for (var i = 0; i < arguments.length; i++) {
finalArgs.push(arguments[i]);
}
return fn.apply(context, finalArgs);
};
} | javascript | function (fn, context) {
var args = [];
for (var i = 2; i < arguments.length; i++) {
args.push(arguments[i]);
}
return function () {
// need to make a copy each time
var finalArgs = args.slice(0);
// concat won't work, as arguments is a special array
for (var i = 0; i < arguments.length; i++) {
finalArgs.push(arguments[i]);
}
return fn.apply(context, finalArgs);
};
} | [
"function",
"(",
"fn",
",",
"context",
")",
"{",
"var",
"args",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"2",
";",
"i",
"<",
"arguments",
".",
"length",
";",
"i",
"++",
")",
"{",
"args",
".",
"push",
"(",
"arguments",
"[",
"i",
"]",
")",
";",
"}",
"return",
"function",
"(",
")",
"{",
"var",
"finalArgs",
"=",
"args",
".",
"slice",
"(",
"0",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"arguments",
".",
"length",
";",
"i",
"++",
")",
"{",
"finalArgs",
".",
"push",
"(",
"arguments",
"[",
"i",
"]",
")",
";",
"}",
"return",
"fn",
".",
"apply",
"(",
"context",
",",
"finalArgs",
")",
";",
"}",
";",
"}"
]
| Bind a function to a particular context. As a consequence, in the function 'this' will correspond to the
context. Additional arguments will be prepend to the arguments of the binded function
@param {Function} fn
@param {Object} context
@return {Function} | [
"Bind",
"a",
"function",
"to",
"a",
"particular",
"context",
".",
"As",
"a",
"consequence",
"in",
"the",
"function",
"this",
"will",
"correspond",
"to",
"the",
"context",
".",
"Additional",
"arguments",
"will",
"be",
"prepend",
"to",
"the",
"arguments",
"of",
"the",
"binded",
"function"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Function.js#L32-L46 | train |
|
ariatemplates/ariatemplates | src/aria/utils/Function.js | function (src, dest, fnNames, prefix) {
if (!prefix) {
prefix = '';
}
for (var index = 0, l = fnNames.length; index < l; index++) {
var key = fnNames[index];
dest[prefix + key] = this.bind(src[key], src);
}
} | javascript | function (src, dest, fnNames, prefix) {
if (!prefix) {
prefix = '';
}
for (var index = 0, l = fnNames.length; index < l; index++) {
var key = fnNames[index];
dest[prefix + key] = this.bind(src[key], src);
}
} | [
"function",
"(",
"src",
",",
"dest",
",",
"fnNames",
",",
"prefix",
")",
"{",
"if",
"(",
"!",
"prefix",
")",
"{",
"prefix",
"=",
"''",
";",
"}",
"for",
"(",
"var",
"index",
"=",
"0",
",",
"l",
"=",
"fnNames",
".",
"length",
";",
"index",
"<",
"l",
";",
"index",
"++",
")",
"{",
"var",
"key",
"=",
"fnNames",
"[",
"index",
"]",
";",
"dest",
"[",
"prefix",
"+",
"key",
"]",
"=",
"this",
".",
"bind",
"(",
"src",
"[",
"key",
"]",
",",
"src",
")",
";",
"}",
"}"
]
| Put on destination object functions from source object, keeping the source object as scope for these
functions
@param {Object} src source object
@param {Object} dest destination object
@param {Array} fnNames list of function names
@param {String} optional string prefix for functions on the target object | [
"Put",
"on",
"destination",
"object",
"functions",
"from",
"source",
"object",
"keeping",
"the",
"source",
"object",
"as",
"scope",
"for",
"these",
"functions"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/Function.js#L56-L64 | train |
|
ariatemplates/ariatemplates | src/aria/widgets/controllers/SelectController.js | function (options) {
var dataModel = this._dataModel;
// normalize labels to lowerCase
var sz = options.length, item;
for (var i = 0; sz > i; i++) {
item = options[i];
item[this.LABEL_META] = item.label.toLowerCase();
}
jsonUtils.setValue(dataModel, 'listContent', options);
this._setDisplayIdx(0);
} | javascript | function (options) {
var dataModel = this._dataModel;
// normalize labels to lowerCase
var sz = options.length, item;
for (var i = 0; sz > i; i++) {
item = options[i];
item[this.LABEL_META] = item.label.toLowerCase();
}
jsonUtils.setValue(dataModel, 'listContent', options);
this._setDisplayIdx(0);
} | [
"function",
"(",
"options",
")",
"{",
"var",
"dataModel",
"=",
"this",
".",
"_dataModel",
";",
"var",
"sz",
"=",
"options",
".",
"length",
",",
"item",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"sz",
">",
"i",
";",
"i",
"++",
")",
"{",
"item",
"=",
"options",
"[",
"i",
"]",
";",
"item",
"[",
"this",
".",
"LABEL_META",
"]",
"=",
"item",
".",
"label",
".",
"toLowerCase",
"(",
")",
";",
"}",
"jsonUtils",
".",
"setValue",
"(",
"dataModel",
",",
"'listContent'",
",",
"options",
")",
";",
"this",
".",
"_setDisplayIdx",
"(",
"0",
")",
";",
"}"
]
| Set the list content
@param {aria.widgets.CfgBeans:SelectCfg.options} options | [
"Set",
"the",
"list",
"content"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/controllers/SelectController.js#L83-L93 | train |
|
ariatemplates/ariatemplates | src/aria/widgets/controllers/SelectController.js | function (includeValue) {
var dataModel = this._dataModel;
var report = new ariaWidgetsControllersReportsDropDownControllerReport();
report.ok = true;
if (includeValue) {
report.value = dataModel.value;
}
report.text = dataModel.displayText;
return report;
} | javascript | function (includeValue) {
var dataModel = this._dataModel;
var report = new ariaWidgetsControllersReportsDropDownControllerReport();
report.ok = true;
if (includeValue) {
report.value = dataModel.value;
}
report.text = dataModel.displayText;
return report;
} | [
"function",
"(",
"includeValue",
")",
"{",
"var",
"dataModel",
"=",
"this",
".",
"_dataModel",
";",
"var",
"report",
"=",
"new",
"ariaWidgetsControllersReportsDropDownControllerReport",
"(",
")",
";",
"report",
".",
"ok",
"=",
"true",
";",
"if",
"(",
"includeValue",
")",
"{",
"report",
".",
"value",
"=",
"dataModel",
".",
"value",
";",
"}",
"report",
".",
"text",
"=",
"dataModel",
".",
"displayText",
";",
"return",
"report",
";",
"}"
]
| Create a report containing the current display value.
@return {aria.widgets.controllers.reports.DropDownControllerReport}
@protected | [
"Create",
"a",
"report",
"containing",
"the",
"current",
"display",
"value",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/controllers/SelectController.js#L100-L109 | train |
|
ariatemplates/ariatemplates | src/aria/widgets/controllers/SelectController.js | function (displayIdx) {
var dataModel = this._dataModel;
var options = dataModel.listContent;
if (options.length === 0) {
displayIdx = -1;
} else if (displayIdx >= options.length) {
displayIdx = options.length - 1;
} else if (displayIdx < 0) {
displayIdx = 0;
}
if (displayIdx == -1) {
jsonUtils.setValue(dataModel, 'selectedIdx', -1);
jsonUtils.setValue(dataModel, 'displayIdx', -1);
jsonUtils.setValue(dataModel, 'displayText', '');
jsonUtils.setValue(dataModel, 'value', null);
} else {
jsonUtils.setValue(dataModel, 'selectedIdx', displayIdx);
jsonUtils.setValue(dataModel, 'displayIdx', displayIdx);
jsonUtils.setValue(dataModel, 'displayText', options[displayIdx].label);
jsonUtils.setValue(dataModel, 'value', options[displayIdx].value);
}
} | javascript | function (displayIdx) {
var dataModel = this._dataModel;
var options = dataModel.listContent;
if (options.length === 0) {
displayIdx = -1;
} else if (displayIdx >= options.length) {
displayIdx = options.length - 1;
} else if (displayIdx < 0) {
displayIdx = 0;
}
if (displayIdx == -1) {
jsonUtils.setValue(dataModel, 'selectedIdx', -1);
jsonUtils.setValue(dataModel, 'displayIdx', -1);
jsonUtils.setValue(dataModel, 'displayText', '');
jsonUtils.setValue(dataModel, 'value', null);
} else {
jsonUtils.setValue(dataModel, 'selectedIdx', displayIdx);
jsonUtils.setValue(dataModel, 'displayIdx', displayIdx);
jsonUtils.setValue(dataModel, 'displayText', options[displayIdx].label);
jsonUtils.setValue(dataModel, 'value', options[displayIdx].value);
}
} | [
"function",
"(",
"displayIdx",
")",
"{",
"var",
"dataModel",
"=",
"this",
".",
"_dataModel",
";",
"var",
"options",
"=",
"dataModel",
".",
"listContent",
";",
"if",
"(",
"options",
".",
"length",
"===",
"0",
")",
"{",
"displayIdx",
"=",
"-",
"1",
";",
"}",
"else",
"if",
"(",
"displayIdx",
">=",
"options",
".",
"length",
")",
"{",
"displayIdx",
"=",
"options",
".",
"length",
"-",
"1",
";",
"}",
"else",
"if",
"(",
"displayIdx",
"<",
"0",
")",
"{",
"displayIdx",
"=",
"0",
";",
"}",
"if",
"(",
"displayIdx",
"==",
"-",
"1",
")",
"{",
"jsonUtils",
".",
"setValue",
"(",
"dataModel",
",",
"'selectedIdx'",
",",
"-",
"1",
")",
";",
"jsonUtils",
".",
"setValue",
"(",
"dataModel",
",",
"'displayIdx'",
",",
"-",
"1",
")",
";",
"jsonUtils",
".",
"setValue",
"(",
"dataModel",
",",
"'displayText'",
",",
"''",
")",
";",
"jsonUtils",
".",
"setValue",
"(",
"dataModel",
",",
"'value'",
",",
"null",
")",
";",
"}",
"else",
"{",
"jsonUtils",
".",
"setValue",
"(",
"dataModel",
",",
"'selectedIdx'",
",",
"displayIdx",
")",
";",
"jsonUtils",
".",
"setValue",
"(",
"dataModel",
",",
"'displayIdx'",
",",
"displayIdx",
")",
";",
"jsonUtils",
".",
"setValue",
"(",
"dataModel",
",",
"'displayText'",
",",
"options",
"[",
"displayIdx",
"]",
".",
"label",
")",
";",
"jsonUtils",
".",
"setValue",
"(",
"dataModel",
",",
"'value'",
",",
"options",
"[",
"displayIdx",
"]",
".",
"value",
")",
";",
"}",
"}"
]
| Set the display index in the data model and update other dependent values.
@param {Number} displayIdx index (in listContent) of the new display text
@protected | [
"Set",
"the",
"display",
"index",
"in",
"the",
"data",
"model",
"and",
"update",
"other",
"dependent",
"values",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/controllers/SelectController.js#L116-L137 | train |
|
ariatemplates/ariatemplates | src/aria/widgets/controllers/SelectController.js | function (lastTypedKeys, newMatch) {
var LABEL_META = this.LABEL_META;
var options = this._dataModel.listContent;
var keyNbr = lastTypedKeys.length;
var index = this._dataModel.selectedIdx + (newMatch ? 1 : 0); // start point to search for a match
for (var ct = 0, optionsLength = options.length; ct < optionsLength; ct++, index++) {
if (index >= optionsLength) {
index = 0;
}
var opt = options[index];
var prefix = opt[LABEL_META].substr(0, keyNbr);
if (prefix == lastTypedKeys) {
return index;
}
}
return -1; // not found
} | javascript | function (lastTypedKeys, newMatch) {
var LABEL_META = this.LABEL_META;
var options = this._dataModel.listContent;
var keyNbr = lastTypedKeys.length;
var index = this._dataModel.selectedIdx + (newMatch ? 1 : 0); // start point to search for a match
for (var ct = 0, optionsLength = options.length; ct < optionsLength; ct++, index++) {
if (index >= optionsLength) {
index = 0;
}
var opt = options[index];
var prefix = opt[LABEL_META].substr(0, keyNbr);
if (prefix == lastTypedKeys) {
return index;
}
}
return -1; // not found
} | [
"function",
"(",
"lastTypedKeys",
",",
"newMatch",
")",
"{",
"var",
"LABEL_META",
"=",
"this",
".",
"LABEL_META",
";",
"var",
"options",
"=",
"this",
".",
"_dataModel",
".",
"listContent",
";",
"var",
"keyNbr",
"=",
"lastTypedKeys",
".",
"length",
";",
"var",
"index",
"=",
"this",
".",
"_dataModel",
".",
"selectedIdx",
"+",
"(",
"newMatch",
"?",
"1",
":",
"0",
")",
";",
"for",
"(",
"var",
"ct",
"=",
"0",
",",
"optionsLength",
"=",
"options",
".",
"length",
";",
"ct",
"<",
"optionsLength",
";",
"ct",
"++",
",",
"index",
"++",
")",
"{",
"if",
"(",
"index",
">=",
"optionsLength",
")",
"{",
"index",
"=",
"0",
";",
"}",
"var",
"opt",
"=",
"options",
"[",
"index",
"]",
";",
"var",
"prefix",
"=",
"opt",
"[",
"LABEL_META",
"]",
".",
"substr",
"(",
"0",
",",
"keyNbr",
")",
";",
"if",
"(",
"prefix",
"==",
"lastTypedKeys",
")",
"{",
"return",
"index",
";",
"}",
"}",
"return",
"-",
"1",
";",
"}"
]
| Search for an item matching the last typed keys in the options and return its index. An item is matching
if the whole lastTypedKeys string is a prefix of its label.
@param {String} lastTypedKeys
@param {Boolean} newMatch
@return {Number} index of the matching item or -1 if no matching item was found
@protected | [
"Search",
"for",
"an",
"item",
"matching",
"the",
"last",
"typed",
"keys",
"in",
"the",
"options",
"and",
"return",
"its",
"index",
".",
"An",
"item",
"is",
"matching",
"if",
"the",
"whole",
"lastTypedKeys",
"string",
"is",
"a",
"prefix",
"of",
"its",
"label",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/controllers/SelectController.js#L179-L195 | train |
|
ariatemplates/ariatemplates | src/aria/widgets/controllers/SelectController.js | function (charCode, keyCode) {
var dataModel = this._dataModel;
var report;
if (domEvent.isNavigationKey(keyCode)) {
var newIdx;
var validationKey = false;
if (keyCode == domEvent.KC_LEFT || keyCode == domEvent.KC_UP) {
newIdx = dataModel.selectedIdx - 1;
} else if (keyCode == domEvent.KC_RIGHT || keyCode == domEvent.KC_DOWN) {
newIdx = dataModel.selectedIdx + 1;
} else if (keyCode == domEvent.KC_PAGE_UP) {
newIdx = dataModel.selectedIdx - (dataModel.pageSize - 1);
} else if (keyCode == domEvent.KC_PAGE_DOWN) {
newIdx = dataModel.selectedIdx + (dataModel.pageSize - 1);
} else if (keyCode == domEvent.KC_HOME) {
newIdx = 0;
} else if (keyCode == domEvent.KC_END) {
newIdx = dataModel.listContent.length - 1;
} else if (keyCode == domEvent.KC_ENTER) {
// when pressing enter, the currently highlighted item in the dropdown becomes the current
// value:
newIdx = dataModel.selectedIdx;
validationKey = true;
} else if (keyCode == domEvent.KC_ESCAPE) {
// pressing escape has no effect if the popup is not open
// it only closes the popup when it is open (does not update the data model)
if (this._listWidget) {
report = this._createReport(false);
report.displayDropDown = false;
report.cancelKeyStroke = true;
jsonUtils.setValue(dataModel, 'selectedIdx', dataModel.displayIdx);
}
} else if (keyCode == domEvent.KC_TAB) {
// when pressing tab, the currently selected item stays the current value:
newIdx = dataModel.displayIdx;
validationKey = true;
}
if (newIdx != null) {
this._setLastTypedKeys(null);
this._setDisplayIdx(newIdx);
report = this._createReport(validationKey);
// never cancel TAB keystroke, and ENTER should not be canceled when the list widget is no
// longer displayed
report.cancelKeyStroke = (keyCode != domEvent.KC_TAB && (keyCode != domEvent.KC_ENTER || this._listWidget != null));
if (this._listWidget && validationKey) {
report.displayDropDown = false;
}
}
} else {
var lastTypedKeys = dataModel.lastTypedKeys;
var newMatch = (lastTypedKeys == null);
if (newMatch) {
lastTypedKeys = "";
}
var newLastTypedKeys;
if (keyCode == domEvent.KC_BACKSPACE) {
newLastTypedKeys = this._getTypedValueOnDelete(keyCode, lastTypedKeys, lastTypedKeys.length, lastTypedKeys.length).nextValue;
// we do not look for a new match when pressing backspace, only save the resulting lastTypedKeys
} else {
newLastTypedKeys = this._getTypedValue(charCode, lastTypedKeys, lastTypedKeys.length, lastTypedKeys.length).nextValue;
newLastTypedKeys = newLastTypedKeys.toLowerCase();
var matchingIndex = this._findMatch(newLastTypedKeys, newMatch);
if (matchingIndex == -1) {
matchingIndex = this._findLetterMatch(newLastTypedKeys);
}
if (matchingIndex > -1) {
this._setDisplayIdx(matchingIndex);
}
}
report = this._createReport(false);
report.cancelKeyStroke = true;
this._setLastTypedKeys(newLastTypedKeys);
}
return report;
} | javascript | function (charCode, keyCode) {
var dataModel = this._dataModel;
var report;
if (domEvent.isNavigationKey(keyCode)) {
var newIdx;
var validationKey = false;
if (keyCode == domEvent.KC_LEFT || keyCode == domEvent.KC_UP) {
newIdx = dataModel.selectedIdx - 1;
} else if (keyCode == domEvent.KC_RIGHT || keyCode == domEvent.KC_DOWN) {
newIdx = dataModel.selectedIdx + 1;
} else if (keyCode == domEvent.KC_PAGE_UP) {
newIdx = dataModel.selectedIdx - (dataModel.pageSize - 1);
} else if (keyCode == domEvent.KC_PAGE_DOWN) {
newIdx = dataModel.selectedIdx + (dataModel.pageSize - 1);
} else if (keyCode == domEvent.KC_HOME) {
newIdx = 0;
} else if (keyCode == domEvent.KC_END) {
newIdx = dataModel.listContent.length - 1;
} else if (keyCode == domEvent.KC_ENTER) {
// when pressing enter, the currently highlighted item in the dropdown becomes the current
// value:
newIdx = dataModel.selectedIdx;
validationKey = true;
} else if (keyCode == domEvent.KC_ESCAPE) {
// pressing escape has no effect if the popup is not open
// it only closes the popup when it is open (does not update the data model)
if (this._listWidget) {
report = this._createReport(false);
report.displayDropDown = false;
report.cancelKeyStroke = true;
jsonUtils.setValue(dataModel, 'selectedIdx', dataModel.displayIdx);
}
} else if (keyCode == domEvent.KC_TAB) {
// when pressing tab, the currently selected item stays the current value:
newIdx = dataModel.displayIdx;
validationKey = true;
}
if (newIdx != null) {
this._setLastTypedKeys(null);
this._setDisplayIdx(newIdx);
report = this._createReport(validationKey);
// never cancel TAB keystroke, and ENTER should not be canceled when the list widget is no
// longer displayed
report.cancelKeyStroke = (keyCode != domEvent.KC_TAB && (keyCode != domEvent.KC_ENTER || this._listWidget != null));
if (this._listWidget && validationKey) {
report.displayDropDown = false;
}
}
} else {
var lastTypedKeys = dataModel.lastTypedKeys;
var newMatch = (lastTypedKeys == null);
if (newMatch) {
lastTypedKeys = "";
}
var newLastTypedKeys;
if (keyCode == domEvent.KC_BACKSPACE) {
newLastTypedKeys = this._getTypedValueOnDelete(keyCode, lastTypedKeys, lastTypedKeys.length, lastTypedKeys.length).nextValue;
// we do not look for a new match when pressing backspace, only save the resulting lastTypedKeys
} else {
newLastTypedKeys = this._getTypedValue(charCode, lastTypedKeys, lastTypedKeys.length, lastTypedKeys.length).nextValue;
newLastTypedKeys = newLastTypedKeys.toLowerCase();
var matchingIndex = this._findMatch(newLastTypedKeys, newMatch);
if (matchingIndex == -1) {
matchingIndex = this._findLetterMatch(newLastTypedKeys);
}
if (matchingIndex > -1) {
this._setDisplayIdx(matchingIndex);
}
}
report = this._createReport(false);
report.cancelKeyStroke = true;
this._setLastTypedKeys(newLastTypedKeys);
}
return report;
} | [
"function",
"(",
"charCode",
",",
"keyCode",
")",
"{",
"var",
"dataModel",
"=",
"this",
".",
"_dataModel",
";",
"var",
"report",
";",
"if",
"(",
"domEvent",
".",
"isNavigationKey",
"(",
"keyCode",
")",
")",
"{",
"var",
"newIdx",
";",
"var",
"validationKey",
"=",
"false",
";",
"if",
"(",
"keyCode",
"==",
"domEvent",
".",
"KC_LEFT",
"||",
"keyCode",
"==",
"domEvent",
".",
"KC_UP",
")",
"{",
"newIdx",
"=",
"dataModel",
".",
"selectedIdx",
"-",
"1",
";",
"}",
"else",
"if",
"(",
"keyCode",
"==",
"domEvent",
".",
"KC_RIGHT",
"||",
"keyCode",
"==",
"domEvent",
".",
"KC_DOWN",
")",
"{",
"newIdx",
"=",
"dataModel",
".",
"selectedIdx",
"+",
"1",
";",
"}",
"else",
"if",
"(",
"keyCode",
"==",
"domEvent",
".",
"KC_PAGE_UP",
")",
"{",
"newIdx",
"=",
"dataModel",
".",
"selectedIdx",
"-",
"(",
"dataModel",
".",
"pageSize",
"-",
"1",
")",
";",
"}",
"else",
"if",
"(",
"keyCode",
"==",
"domEvent",
".",
"KC_PAGE_DOWN",
")",
"{",
"newIdx",
"=",
"dataModel",
".",
"selectedIdx",
"+",
"(",
"dataModel",
".",
"pageSize",
"-",
"1",
")",
";",
"}",
"else",
"if",
"(",
"keyCode",
"==",
"domEvent",
".",
"KC_HOME",
")",
"{",
"newIdx",
"=",
"0",
";",
"}",
"else",
"if",
"(",
"keyCode",
"==",
"domEvent",
".",
"KC_END",
")",
"{",
"newIdx",
"=",
"dataModel",
".",
"listContent",
".",
"length",
"-",
"1",
";",
"}",
"else",
"if",
"(",
"keyCode",
"==",
"domEvent",
".",
"KC_ENTER",
")",
"{",
"newIdx",
"=",
"dataModel",
".",
"selectedIdx",
";",
"validationKey",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"keyCode",
"==",
"domEvent",
".",
"KC_ESCAPE",
")",
"{",
"if",
"(",
"this",
".",
"_listWidget",
")",
"{",
"report",
"=",
"this",
".",
"_createReport",
"(",
"false",
")",
";",
"report",
".",
"displayDropDown",
"=",
"false",
";",
"report",
".",
"cancelKeyStroke",
"=",
"true",
";",
"jsonUtils",
".",
"setValue",
"(",
"dataModel",
",",
"'selectedIdx'",
",",
"dataModel",
".",
"displayIdx",
")",
";",
"}",
"}",
"else",
"if",
"(",
"keyCode",
"==",
"domEvent",
".",
"KC_TAB",
")",
"{",
"newIdx",
"=",
"dataModel",
".",
"displayIdx",
";",
"validationKey",
"=",
"true",
";",
"}",
"if",
"(",
"newIdx",
"!=",
"null",
")",
"{",
"this",
".",
"_setLastTypedKeys",
"(",
"null",
")",
";",
"this",
".",
"_setDisplayIdx",
"(",
"newIdx",
")",
";",
"report",
"=",
"this",
".",
"_createReport",
"(",
"validationKey",
")",
";",
"report",
".",
"cancelKeyStroke",
"=",
"(",
"keyCode",
"!=",
"domEvent",
".",
"KC_TAB",
"&&",
"(",
"keyCode",
"!=",
"domEvent",
".",
"KC_ENTER",
"||",
"this",
".",
"_listWidget",
"!=",
"null",
")",
")",
";",
"if",
"(",
"this",
".",
"_listWidget",
"&&",
"validationKey",
")",
"{",
"report",
".",
"displayDropDown",
"=",
"false",
";",
"}",
"}",
"}",
"else",
"{",
"var",
"lastTypedKeys",
"=",
"dataModel",
".",
"lastTypedKeys",
";",
"var",
"newMatch",
"=",
"(",
"lastTypedKeys",
"==",
"null",
")",
";",
"if",
"(",
"newMatch",
")",
"{",
"lastTypedKeys",
"=",
"\"\"",
";",
"}",
"var",
"newLastTypedKeys",
";",
"if",
"(",
"keyCode",
"==",
"domEvent",
".",
"KC_BACKSPACE",
")",
"{",
"newLastTypedKeys",
"=",
"this",
".",
"_getTypedValueOnDelete",
"(",
"keyCode",
",",
"lastTypedKeys",
",",
"lastTypedKeys",
".",
"length",
",",
"lastTypedKeys",
".",
"length",
")",
".",
"nextValue",
";",
"}",
"else",
"{",
"newLastTypedKeys",
"=",
"this",
".",
"_getTypedValue",
"(",
"charCode",
",",
"lastTypedKeys",
",",
"lastTypedKeys",
".",
"length",
",",
"lastTypedKeys",
".",
"length",
")",
".",
"nextValue",
";",
"newLastTypedKeys",
"=",
"newLastTypedKeys",
".",
"toLowerCase",
"(",
")",
";",
"var",
"matchingIndex",
"=",
"this",
".",
"_findMatch",
"(",
"newLastTypedKeys",
",",
"newMatch",
")",
";",
"if",
"(",
"matchingIndex",
"==",
"-",
"1",
")",
"{",
"matchingIndex",
"=",
"this",
".",
"_findLetterMatch",
"(",
"newLastTypedKeys",
")",
";",
"}",
"if",
"(",
"matchingIndex",
">",
"-",
"1",
")",
"{",
"this",
".",
"_setDisplayIdx",
"(",
"matchingIndex",
")",
";",
"}",
"}",
"report",
"=",
"this",
".",
"_createReport",
"(",
"false",
")",
";",
"report",
".",
"cancelKeyStroke",
"=",
"true",
";",
"this",
".",
"_setLastTypedKeys",
"(",
"newLastTypedKeys",
")",
";",
"}",
"return",
"report",
";",
"}"
]
| Verify a given keyStroke and return a report.
@param {Integer} charCode
@param {Integer} keyCode
@return {aria.widgets.controllers.reports.DropDownControllerReport} | [
"Verify",
"a",
"given",
"keyStroke",
"and",
"return",
"a",
"report",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/controllers/SelectController.js#L230-L304 | train |
|
ariatemplates/ariatemplates | src/aria/widgets/controllers/SelectController.js | function (internalValue) {
var options = this._dataModel.listContent;
var indexFound = -1;
for (var i = 0, l = options.length; i < l; i++) {
if (options[i].value == internalValue) {
indexFound = i;
break;
}
}
this._setDisplayIdx(indexFound);
return this._createReport(true);
} | javascript | function (internalValue) {
var options = this._dataModel.listContent;
var indexFound = -1;
for (var i = 0, l = options.length; i < l; i++) {
if (options[i].value == internalValue) {
indexFound = i;
break;
}
}
this._setDisplayIdx(indexFound);
return this._createReport(true);
} | [
"function",
"(",
"internalValue",
")",
"{",
"var",
"options",
"=",
"this",
".",
"_dataModel",
".",
"listContent",
";",
"var",
"indexFound",
"=",
"-",
"1",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"options",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"if",
"(",
"options",
"[",
"i",
"]",
".",
"value",
"==",
"internalValue",
")",
"{",
"indexFound",
"=",
"i",
";",
"break",
";",
"}",
"}",
"this",
".",
"_setDisplayIdx",
"(",
"indexFound",
")",
";",
"return",
"this",
".",
"_createReport",
"(",
"true",
")",
";",
"}"
]
| Verify a given value and return a report.
@param {String} internalValue value
@return {aria.widgets.controllers.reports.DropDownControllerReport} | [
"Verify",
"a",
"given",
"value",
"and",
"return",
"a",
"report",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/controllers/SelectController.js#L311-L322 | train |
|
ariatemplates/ariatemplates | src/aria/widgets/controllers/SelectController.js | function () {
var report = new ariaWidgetsControllersReportsDropDownControllerReport();
report.displayDropDown = (this._listWidget == null);
if (this._dataModel && this._dataModel.displayIdx !== this._dataModel.selectedIdx) {
this._setDisplayIdx(this._dataModel.displayIdx);
}
return report;
} | javascript | function () {
var report = new ariaWidgetsControllersReportsDropDownControllerReport();
report.displayDropDown = (this._listWidget == null);
if (this._dataModel && this._dataModel.displayIdx !== this._dataModel.selectedIdx) {
this._setDisplayIdx(this._dataModel.displayIdx);
}
return report;
} | [
"function",
"(",
")",
"{",
"var",
"report",
"=",
"new",
"ariaWidgetsControllersReportsDropDownControllerReport",
"(",
")",
";",
"report",
".",
"displayDropDown",
"=",
"(",
"this",
".",
"_listWidget",
"==",
"null",
")",
";",
"if",
"(",
"this",
".",
"_dataModel",
"&&",
"this",
".",
"_dataModel",
".",
"displayIdx",
"!==",
"this",
".",
"_dataModel",
".",
"selectedIdx",
")",
"{",
"this",
".",
"_setDisplayIdx",
"(",
"this",
".",
"_dataModel",
".",
"displayIdx",
")",
";",
"}",
"return",
"report",
";",
"}"
]
| Called when the user wants to toggle the display of the dropdown.
@return {aria.widgets.controllers.reports.DropDownControllerReport} | [
"Called",
"when",
"the",
"user",
"wants",
"to",
"toggle",
"the",
"display",
"of",
"the",
"dropdown",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/controllers/SelectController.js#L347-L354 | train |
|
ariatemplates/ariatemplates | src/aria/utils/sandbox/DOMProperties.js | function (tagName, propertyName) {
if (!__properties.hasOwnProperty(propertyName)) {
return "--";
}
var property = __properties[propertyName];
if (typeof property == "object") {
tagName = tagName.toUpperCase();
if (!property.hasOwnProperty(tagName)) {
return "--";
}
property = property[tagName];
}
return property;
} | javascript | function (tagName, propertyName) {
if (!__properties.hasOwnProperty(propertyName)) {
return "--";
}
var property = __properties[propertyName];
if (typeof property == "object") {
tagName = tagName.toUpperCase();
if (!property.hasOwnProperty(tagName)) {
return "--";
}
property = property[tagName];
}
return property;
} | [
"function",
"(",
"tagName",
",",
"propertyName",
")",
"{",
"if",
"(",
"!",
"__properties",
".",
"hasOwnProperty",
"(",
"propertyName",
")",
")",
"{",
"return",
"\"--\"",
";",
"}",
"var",
"property",
"=",
"__properties",
"[",
"propertyName",
"]",
";",
"if",
"(",
"typeof",
"property",
"==",
"\"object\"",
")",
"{",
"tagName",
"=",
"tagName",
".",
"toUpperCase",
"(",
")",
";",
"if",
"(",
"!",
"property",
".",
"hasOwnProperty",
"(",
"tagName",
")",
")",
"{",
"return",
"\"--\"",
";",
"}",
"property",
"=",
"property",
"[",
"tagName",
"]",
";",
"}",
"return",
"property",
";",
"}"
]
| Gives information about what access should be granted for a given property of a DOM element of a given
type.
@param {String} tagName tag name (this is case insensitive, for example "a" and "A" are equivalent)
@param {String} propertyName property name (this is case sensitive)
@return {String} "--" for no access, "r-" for read-only access, "rw" for read-write access | [
"Gives",
"information",
"about",
"what",
"access",
"should",
"be",
"granted",
"for",
"a",
"given",
"property",
"of",
"a",
"DOM",
"element",
"of",
"a",
"given",
"type",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/sandbox/DOMProperties.js#L336-L349 | train |
|
ariatemplates/ariatemplates | src/aria/Aria.js | function (path, context) {
if (!path || typeof(path) != 'string') {
Aria.$logError(Aria.NULL_CLASSPATH);
return false;
}
var classpathParts = path.split('.'), nbParts = classpathParts.length;
for (var index = 0; index < nbParts - 1; index++) {
if (!__checkPackageName(classpathParts[index], context)) {
return false;
}
}
if (!__checkClassName(classpathParts[nbParts - 1], context)) {
return false;
}
return true;
} | javascript | function (path, context) {
if (!path || typeof(path) != 'string') {
Aria.$logError(Aria.NULL_CLASSPATH);
return false;
}
var classpathParts = path.split('.'), nbParts = classpathParts.length;
for (var index = 0; index < nbParts - 1; index++) {
if (!__checkPackageName(classpathParts[index], context)) {
return false;
}
}
if (!__checkClassName(classpathParts[nbParts - 1], context)) {
return false;
}
return true;
} | [
"function",
"(",
"path",
",",
"context",
")",
"{",
"if",
"(",
"!",
"path",
"||",
"typeof",
"(",
"path",
")",
"!=",
"'string'",
")",
"{",
"Aria",
".",
"$logError",
"(",
"Aria",
".",
"NULL_CLASSPATH",
")",
";",
"return",
"false",
";",
"}",
"var",
"classpathParts",
"=",
"path",
".",
"split",
"(",
"'.'",
")",
",",
"nbParts",
"=",
"classpathParts",
".",
"length",
";",
"for",
"(",
"var",
"index",
"=",
"0",
";",
"index",
"<",
"nbParts",
"-",
"1",
";",
"index",
"++",
")",
"{",
"if",
"(",
"!",
"__checkPackageName",
"(",
"classpathParts",
"[",
"index",
"]",
",",
"context",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"if",
"(",
"!",
"__checkClassName",
"(",
"classpathParts",
"[",
"nbParts",
"-",
"1",
"]",
",",
"context",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
]
| Classpath validation method
@param {String} path class path to validate - e.g. 'aria.jsunit.TestSuite'
@param {String} context additional context information
@return {Boolean} true if class path is OK | [
"Classpath",
"validation",
"method"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/Aria.js#L211-L226 | train |
|
ariatemplates/ariatemplates | src/aria/Aria.js | function (className, context) {
context = context || '';
if (!className || !className.match(/^[_A-Z]\w*$/)) {
Aria.$logError(Aria.INVALID_CLASSNAME_FORMAT, [className, context]);
return false;
}
if (Aria.isJsReservedWord(className)) {
Aria.$logError(Aria.INVALID_CLASSNAME_RESERVED, [className, context]);
return false;
}
return true;
} | javascript | function (className, context) {
context = context || '';
if (!className || !className.match(/^[_A-Z]\w*$/)) {
Aria.$logError(Aria.INVALID_CLASSNAME_FORMAT, [className, context]);
return false;
}
if (Aria.isJsReservedWord(className)) {
Aria.$logError(Aria.INVALID_CLASSNAME_RESERVED, [className, context]);
return false;
}
return true;
} | [
"function",
"(",
"className",
",",
"context",
")",
"{",
"context",
"=",
"context",
"||",
"''",
";",
"if",
"(",
"!",
"className",
"||",
"!",
"className",
".",
"match",
"(",
"/",
"^[_A-Z]\\w*$",
"/",
")",
")",
"{",
"Aria",
".",
"$logError",
"(",
"Aria",
".",
"INVALID_CLASSNAME_FORMAT",
",",
"[",
"className",
",",
"context",
"]",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"Aria",
".",
"isJsReservedWord",
"(",
"className",
")",
")",
"{",
"Aria",
".",
"$logError",
"(",
"Aria",
".",
"INVALID_CLASSNAME_RESERVED",
",",
"[",
"className",
",",
"context",
"]",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
]
| Class name validation method
@param {String} className class name to validate - e.g. 'TestSuite'
@param {String} context additional context information
@return {Boolean} true if class path is OK | [
"Class",
"name",
"validation",
"method"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/Aria.js#L234-L245 | train |
|
ariatemplates/ariatemplates | src/aria/Aria.js | function (packageName, context) {
context = context || '';
if (!packageName) {
Aria.$logError(Aria.INVALID_PACKAGENAME_FORMAT, [packageName, context]);
return false;
}
if (Aria.isJsReservedWord(packageName)) {
Aria.$logError(Aria.INVALID_PACKAGENAME_RESERVED, [packageName, context]);
return false;
}
if (!packageName.match(/^[a-z]\w*$/)) {
Aria.$logInfo(Aria.INVALID_PACKAGENAME_FORMAT, [packageName, context]);
}
return true;
} | javascript | function (packageName, context) {
context = context || '';
if (!packageName) {
Aria.$logError(Aria.INVALID_PACKAGENAME_FORMAT, [packageName, context]);
return false;
}
if (Aria.isJsReservedWord(packageName)) {
Aria.$logError(Aria.INVALID_PACKAGENAME_RESERVED, [packageName, context]);
return false;
}
if (!packageName.match(/^[a-z]\w*$/)) {
Aria.$logInfo(Aria.INVALID_PACKAGENAME_FORMAT, [packageName, context]);
}
return true;
} | [
"function",
"(",
"packageName",
",",
"context",
")",
"{",
"context",
"=",
"context",
"||",
"''",
";",
"if",
"(",
"!",
"packageName",
")",
"{",
"Aria",
".",
"$logError",
"(",
"Aria",
".",
"INVALID_PACKAGENAME_FORMAT",
",",
"[",
"packageName",
",",
"context",
"]",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"Aria",
".",
"isJsReservedWord",
"(",
"packageName",
")",
")",
"{",
"Aria",
".",
"$logError",
"(",
"Aria",
".",
"INVALID_PACKAGENAME_RESERVED",
",",
"[",
"packageName",
",",
"context",
"]",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"packageName",
".",
"match",
"(",
"/",
"^[a-z]\\w*$",
"/",
")",
")",
"{",
"Aria",
".",
"$logInfo",
"(",
"Aria",
".",
"INVALID_PACKAGENAME_FORMAT",
",",
"[",
"packageName",
",",
"context",
"]",
")",
";",
"}",
"return",
"true",
";",
"}"
]
| Package name validation method
@param {String} packageName package name to validate - e.g. 'TestSuite'
@param {String} context additional context information
@return {Boolean} true if class path is OK | [
"Package",
"name",
"validation",
"method"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/Aria.js#L253-L267 | train |
|
ariatemplates/ariatemplates | src/aria/Aria.js | function (obj, def, superclass, fn, params) {
var newcall = (!obj["aria:nextCall"]);
if (!newcall && obj["aria:nextCall"] != def.$classpath) {
Aria.$logError(Aria.WRONGPARENT_CALLED, [fn, def.$classpath, obj["aria:nextCall"], obj.$classpath]);
}
obj["aria:nextCall"] = (superclass ? superclass.classDefinition.$classpath : null);
if (def[fn]) {
def[fn].apply(obj, params);
} else if (superclass && fn == "$destructor") {
// no destructor: must call the parent destructor, by default
superclass.prototype.$destructor.apply(obj, params);
}
if (obj["aria:nextCall"] && obj["aria:nextCall"] != "aria.core.JsObject") {
Aria.$logError(Aria.PARENT_NOTCALLED, [fn, obj["aria:nextCall"], def.$classpath]);
}
if (newcall) {
obj["aria:nextCall"] = undefined;
}
return newcall;
} | javascript | function (obj, def, superclass, fn, params) {
var newcall = (!obj["aria:nextCall"]);
if (!newcall && obj["aria:nextCall"] != def.$classpath) {
Aria.$logError(Aria.WRONGPARENT_CALLED, [fn, def.$classpath, obj["aria:nextCall"], obj.$classpath]);
}
obj["aria:nextCall"] = (superclass ? superclass.classDefinition.$classpath : null);
if (def[fn]) {
def[fn].apply(obj, params);
} else if (superclass && fn == "$destructor") {
// no destructor: must call the parent destructor, by default
superclass.prototype.$destructor.apply(obj, params);
}
if (obj["aria:nextCall"] && obj["aria:nextCall"] != "aria.core.JsObject") {
Aria.$logError(Aria.PARENT_NOTCALLED, [fn, obj["aria:nextCall"], def.$classpath]);
}
if (newcall) {
obj["aria:nextCall"] = undefined;
}
return newcall;
} | [
"function",
"(",
"obj",
",",
"def",
",",
"superclass",
",",
"fn",
",",
"params",
")",
"{",
"var",
"newcall",
"=",
"(",
"!",
"obj",
"[",
"\"aria:nextCall\"",
"]",
")",
";",
"if",
"(",
"!",
"newcall",
"&&",
"obj",
"[",
"\"aria:nextCall\"",
"]",
"!=",
"def",
".",
"$classpath",
")",
"{",
"Aria",
".",
"$logError",
"(",
"Aria",
".",
"WRONGPARENT_CALLED",
",",
"[",
"fn",
",",
"def",
".",
"$classpath",
",",
"obj",
"[",
"\"aria:nextCall\"",
"]",
",",
"obj",
".",
"$classpath",
"]",
")",
";",
"}",
"obj",
"[",
"\"aria:nextCall\"",
"]",
"=",
"(",
"superclass",
"?",
"superclass",
".",
"classDefinition",
".",
"$classpath",
":",
"null",
")",
";",
"if",
"(",
"def",
"[",
"fn",
"]",
")",
"{",
"def",
"[",
"fn",
"]",
".",
"apply",
"(",
"obj",
",",
"params",
")",
";",
"}",
"else",
"if",
"(",
"superclass",
"&&",
"fn",
"==",
"\"$destructor\"",
")",
"{",
"superclass",
".",
"prototype",
".",
"$destructor",
".",
"apply",
"(",
"obj",
",",
"params",
")",
";",
"}",
"if",
"(",
"obj",
"[",
"\"aria:nextCall\"",
"]",
"&&",
"obj",
"[",
"\"aria:nextCall\"",
"]",
"!=",
"\"aria.core.JsObject\"",
")",
"{",
"Aria",
".",
"$logError",
"(",
"Aria",
".",
"PARENT_NOTCALLED",
",",
"[",
"fn",
",",
"obj",
"[",
"\"aria:nextCall\"",
"]",
",",
"def",
".",
"$classpath",
"]",
")",
";",
"}",
"if",
"(",
"newcall",
")",
"{",
"obj",
"[",
"\"aria:nextCall\"",
"]",
"=",
"undefined",
";",
"}",
"return",
"newcall",
";",
"}"
]
| Wrapper function for constructors or destructors on an object. It is used only when Aria.memCheckMode==true. When
the constructor or destructor of an object is called, this function is called, and this function calls the
corresponding constructor or destructor in the object definition and check that it calls its parent constructor
or destructor.
@private
@param {Object} object
@param {Object} definition object definition whose constructor should be called
@param {Object} superclass superclass
@param {String} fn May be "$constructor" or "$destructor".
@param {Array} params Array of parameters to be given to the $constructor; should be empty when fn=="$destructor"
return true if it was the first call | [
"Wrapper",
"function",
"for",
"constructors",
"or",
"destructors",
"on",
"an",
"object",
".",
"It",
"is",
"used",
"only",
"when",
"Aria",
".",
"memCheckMode",
"==",
"true",
".",
"When",
"the",
"constructor",
"or",
"destructor",
"of",
"an",
"object",
"is",
"called",
"this",
"function",
"is",
"called",
"and",
"this",
"function",
"calls",
"the",
"corresponding",
"constructor",
"or",
"destructor",
"in",
"the",
"object",
"definition",
"and",
"check",
"that",
"it",
"calls",
"its",
"parent",
"constructor",
"or",
"destructor",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/Aria.js#L303-L322 | train |
|
ariatemplates/ariatemplates | src/aria/Aria.js | function (mergeTo, mergeFrom, classpathTo) {
var hasEvents = false;
for (var k in mergeFrom) {
if (mergeFrom.hasOwnProperty(k)) {
if (!hasEvents) {
hasEvents = true;
}
// The comparison with null below is important, as an empty string is a valid event description.
if (mergeTo[k] != null) {
Aria.$logError(Aria.REDECLARED_EVENT, [k, classpathTo]);
} else {
mergeTo[k] = mergeFrom[k];
}
}
}
return hasEvents;
} | javascript | function (mergeTo, mergeFrom, classpathTo) {
var hasEvents = false;
for (var k in mergeFrom) {
if (mergeFrom.hasOwnProperty(k)) {
if (!hasEvents) {
hasEvents = true;
}
// The comparison with null below is important, as an empty string is a valid event description.
if (mergeTo[k] != null) {
Aria.$logError(Aria.REDECLARED_EVENT, [k, classpathTo]);
} else {
mergeTo[k] = mergeFrom[k];
}
}
}
return hasEvents;
} | [
"function",
"(",
"mergeTo",
",",
"mergeFrom",
",",
"classpathTo",
")",
"{",
"var",
"hasEvents",
"=",
"false",
";",
"for",
"(",
"var",
"k",
"in",
"mergeFrom",
")",
"{",
"if",
"(",
"mergeFrom",
".",
"hasOwnProperty",
"(",
"k",
")",
")",
"{",
"if",
"(",
"!",
"hasEvents",
")",
"{",
"hasEvents",
"=",
"true",
";",
"}",
"if",
"(",
"mergeTo",
"[",
"k",
"]",
"!=",
"null",
")",
"{",
"Aria",
".",
"$logError",
"(",
"Aria",
".",
"REDECLARED_EVENT",
",",
"[",
"k",
",",
"classpathTo",
"]",
")",
";",
"}",
"else",
"{",
"mergeTo",
"[",
"k",
"]",
"=",
"mergeFrom",
"[",
"k",
"]",
";",
"}",
"}",
"}",
"return",
"hasEvents",
";",
"}"
]
| Copies the content of mergeFrom into mergeTo. mergeFrom and mergeTo are maps of event definitions. If an event
declared in mergeFrom already exists in mergeTo, the error is logged and the event is not overriden.
@name Aria.__mergeEvents
@private
@method
@param {Object} mergeTo Destrination object (map of events).
@param {Object} mergeFrom Source object (map of events).
@param {String} Classpath of the object to which events are copied. Used in case of error.
@return {Boolean} false if mergeFrom is empty. True otherwise. | [
"Copies",
"the",
"content",
"of",
"mergeFrom",
"into",
"mergeTo",
".",
"mergeFrom",
"and",
"mergeTo",
"are",
"maps",
"of",
"event",
"definitions",
".",
"If",
"an",
"event",
"declared",
"in",
"mergeFrom",
"already",
"exists",
"in",
"mergeTo",
"the",
"error",
"is",
"logged",
"and",
"the",
"event",
"is",
"not",
"overriden",
"."
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/Aria.js#L438-L454 | train |
|
ariatemplates/ariatemplates | src/aria/storage/AbstractStorage.js | function (options) {
/**
* Whether the serializer instance should be disposed when this instance is disposed
* @type Boolean
* @protected
*/
this._disposeSerializer = false;
/**
* Callback for storage events
* @type aria.core.CfgBeans:Callback
*/
this._eventCallback = {
fn : this._onStorageEvent,
scope : this
};
// listen to events raised by other instances on the same window
ariaStorageEventBus.$on({
"change" : this._eventCallback
});
var serializer = options ? options.serializer : null, create = true;
if (serializer) {
if ("serialize" in serializer && "parse" in serializer) {
// There is a serializer matching the interface, it's the only case where we don't have to create a
// new instance
create = false;
} else {
this.$logError(this.INVALID_SERIALIZER);
}
}
if (create) {
serializer = new ariaUtilsJsonJsonSerializer(true);
this._disposeSerializer = true;
}
/**
* Serializer instance
* @type aria.utils.json.ISerializer
*/
this.serializer = serializer;
var nspace = "";
if (options && options.namespace) {
if (!ariaUtilsType.isString(options.namespace)) {
this.$logError(this.INVALID_NAMESPACE);
} else {
// The dollar is just there to separate the keys from the namespace
nspace = options.namespace + "$";
}
}
/**
* Namespace. It's the prefix used to store keys. It's a sort of security feature altough it doesn't provide
* much of it.
* @type String
*/
this.namespace = nspace;
} | javascript | function (options) {
/**
* Whether the serializer instance should be disposed when this instance is disposed
* @type Boolean
* @protected
*/
this._disposeSerializer = false;
/**
* Callback for storage events
* @type aria.core.CfgBeans:Callback
*/
this._eventCallback = {
fn : this._onStorageEvent,
scope : this
};
// listen to events raised by other instances on the same window
ariaStorageEventBus.$on({
"change" : this._eventCallback
});
var serializer = options ? options.serializer : null, create = true;
if (serializer) {
if ("serialize" in serializer && "parse" in serializer) {
// There is a serializer matching the interface, it's the only case where we don't have to create a
// new instance
create = false;
} else {
this.$logError(this.INVALID_SERIALIZER);
}
}
if (create) {
serializer = new ariaUtilsJsonJsonSerializer(true);
this._disposeSerializer = true;
}
/**
* Serializer instance
* @type aria.utils.json.ISerializer
*/
this.serializer = serializer;
var nspace = "";
if (options && options.namespace) {
if (!ariaUtilsType.isString(options.namespace)) {
this.$logError(this.INVALID_NAMESPACE);
} else {
// The dollar is just there to separate the keys from the namespace
nspace = options.namespace + "$";
}
}
/**
* Namespace. It's the prefix used to store keys. It's a sort of security feature altough it doesn't provide
* much of it.
* @type String
*/
this.namespace = nspace;
} | [
"function",
"(",
"options",
")",
"{",
"this",
".",
"_disposeSerializer",
"=",
"false",
";",
"this",
".",
"_eventCallback",
"=",
"{",
"fn",
":",
"this",
".",
"_onStorageEvent",
",",
"scope",
":",
"this",
"}",
";",
"ariaStorageEventBus",
".",
"$on",
"(",
"{",
"\"change\"",
":",
"this",
".",
"_eventCallback",
"}",
")",
";",
"var",
"serializer",
"=",
"options",
"?",
"options",
".",
"serializer",
":",
"null",
",",
"create",
"=",
"true",
";",
"if",
"(",
"serializer",
")",
"{",
"if",
"(",
"\"serialize\"",
"in",
"serializer",
"&&",
"\"parse\"",
"in",
"serializer",
")",
"{",
"create",
"=",
"false",
";",
"}",
"else",
"{",
"this",
".",
"$logError",
"(",
"this",
".",
"INVALID_SERIALIZER",
")",
";",
"}",
"}",
"if",
"(",
"create",
")",
"{",
"serializer",
"=",
"new",
"ariaUtilsJsonJsonSerializer",
"(",
"true",
")",
";",
"this",
".",
"_disposeSerializer",
"=",
"true",
";",
"}",
"this",
".",
"serializer",
"=",
"serializer",
";",
"var",
"nspace",
"=",
"\"\"",
";",
"if",
"(",
"options",
"&&",
"options",
".",
"namespace",
")",
"{",
"if",
"(",
"!",
"ariaUtilsType",
".",
"isString",
"(",
"options",
".",
"namespace",
")",
")",
"{",
"this",
".",
"$logError",
"(",
"this",
".",
"INVALID_NAMESPACE",
")",
";",
"}",
"else",
"{",
"nspace",
"=",
"options",
".",
"namespace",
"+",
"\"$\"",
";",
"}",
"}",
"this",
".",
"namespace",
"=",
"nspace",
";",
"}"
]
| Create an abstract instance of storage
@param {aria.storage.Beans:ConstructorArgs} options Constructor options | [
"Create",
"an",
"abstract",
"instance",
"of",
"storage"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/storage/AbstractStorage.js#L48-L106 | train |
|
ariatemplates/ariatemplates | src/aria/storage/AbstractStorage.js | function (event) {
if (event.key === null || event.namespace === this.namespace) {
var lessDetailedEvent = ariaUtilsJson.copy(event, false, this.EVENT_KEYS);
this.$raiseEvent(lessDetailedEvent);
}
} | javascript | function (event) {
if (event.key === null || event.namespace === this.namespace) {
var lessDetailedEvent = ariaUtilsJson.copy(event, false, this.EVENT_KEYS);
this.$raiseEvent(lessDetailedEvent);
}
} | [
"function",
"(",
"event",
")",
"{",
"if",
"(",
"event",
".",
"key",
"===",
"null",
"||",
"event",
".",
"namespace",
"===",
"this",
".",
"namespace",
")",
"{",
"var",
"lessDetailedEvent",
"=",
"ariaUtilsJson",
".",
"copy",
"(",
"event",
",",
"false",
",",
"this",
".",
"EVENT_KEYS",
")",
";",
"this",
".",
"$raiseEvent",
"(",
"lessDetailedEvent",
")",
";",
"}",
"}"
]
| React to storage event coming from the EventBus. This function raises an Aria Templates event making sure
that it's not raised when namespacing is applied
@param {HTMLEvent} event Event raised by the browser | [
"React",
"to",
"storage",
"event",
"coming",
"from",
"the",
"EventBus",
".",
"This",
"function",
"raises",
"an",
"Aria",
"Templates",
"event",
"making",
"sure",
"that",
"it",
"s",
"not",
"raised",
"when",
"namespacing",
"is",
"applied"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/storage/AbstractStorage.js#L193-L198 | train |
|
ariatemplates/ariatemplates | src/aria/tools/inspector/TemplateInspectorScript.js | function (event, widgetDesc) {
var widget = widgetDesc.widget;
var domElt = widget.getDom();
if (domElt) {
this.moduleCtrl.displayHighlight(domElt, "#FF6666");
}
this.mouseOver(event);
event.stopPropagation();
} | javascript | function (event, widgetDesc) {
var widget = widgetDesc.widget;
var domElt = widget.getDom();
if (domElt) {
this.moduleCtrl.displayHighlight(domElt, "#FF6666");
}
this.mouseOver(event);
event.stopPropagation();
} | [
"function",
"(",
"event",
",",
"widgetDesc",
")",
"{",
"var",
"widget",
"=",
"widgetDesc",
".",
"widget",
";",
"var",
"domElt",
"=",
"widget",
".",
"getDom",
"(",
")",
";",
"if",
"(",
"domElt",
")",
"{",
"this",
".",
"moduleCtrl",
".",
"displayHighlight",
"(",
"domElt",
",",
"\"#FF6666\"",
")",
";",
"}",
"this",
".",
"mouseOver",
"(",
"event",
")",
";",
"event",
".",
"stopPropagation",
"(",
")",
";",
"}"
]
| Highlight a widget in the application on mouseover
@param {Object} event
@param {Object} widgetDesc description | [
"Highlight",
"a",
"widget",
"in",
"the",
"application",
"on",
"mouseover"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/tools/inspector/TemplateInspectorScript.js#L32-L40 | train |
|
ariatemplates/ariatemplates | src/aria/tools/inspector/TemplateInspectorScript.js | function (event) {
this.data.showSource = !this.data.showSource;
if (this.data.showSource) {
this.data.initialSource = true;
var filePath = this.data.templateCtxt.tplClasspath.replace(/\./g, "/") + ".tpl";
this.data.source = this.moduleCtrl.getSource(filePath).value;
}
this.$refresh();
} | javascript | function (event) {
this.data.showSource = !this.data.showSource;
if (this.data.showSource) {
this.data.initialSource = true;
var filePath = this.data.templateCtxt.tplClasspath.replace(/\./g, "/") + ".tpl";
this.data.source = this.moduleCtrl.getSource(filePath).value;
}
this.$refresh();
} | [
"function",
"(",
"event",
")",
"{",
"this",
".",
"data",
".",
"showSource",
"=",
"!",
"this",
".",
"data",
".",
"showSource",
";",
"if",
"(",
"this",
".",
"data",
".",
"showSource",
")",
"{",
"this",
".",
"data",
".",
"initialSource",
"=",
"true",
";",
"var",
"filePath",
"=",
"this",
".",
"data",
".",
"templateCtxt",
".",
"tplClasspath",
".",
"replace",
"(",
"/",
"\\.",
"/",
"g",
",",
"\"/\"",
")",
"+",
"\".tpl\"",
";",
"this",
".",
"data",
".",
"source",
"=",
"this",
".",
"moduleCtrl",
".",
"getSource",
"(",
"filePath",
")",
".",
"value",
";",
"}",
"this",
".",
"$refresh",
"(",
")",
";",
"}"
]
| Change visibility of source, and retrieve it if not available
@param {aria.DomEvent} event | [
"Change",
"visibility",
"of",
"source",
"and",
"retrieve",
"it",
"if",
"not",
"available"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/tools/inspector/TemplateInspectorScript.js#L114-L122 | train |
|
ariatemplates/ariatemplates | src/aria/tools/inspector/TemplateInspectorScript.js | function (event) {
if (this.data.initialSource) {
ariaUtilsJson.setValue(this.data, "initialSource", false);
this.$refresh({
section : "controls"
});
}
this.data.tplSrcEdit = event.target.getValue();
} | javascript | function (event) {
if (this.data.initialSource) {
ariaUtilsJson.setValue(this.data, "initialSource", false);
this.$refresh({
section : "controls"
});
}
this.data.tplSrcEdit = event.target.getValue();
} | [
"function",
"(",
"event",
")",
"{",
"if",
"(",
"this",
".",
"data",
".",
"initialSource",
")",
"{",
"ariaUtilsJson",
".",
"setValue",
"(",
"this",
".",
"data",
",",
"\"initialSource\"",
",",
"false",
")",
";",
"this",
".",
"$refresh",
"(",
"{",
"section",
":",
"\"controls\"",
"}",
")",
";",
"}",
"this",
".",
"data",
".",
"tplSrcEdit",
"=",
"event",
".",
"target",
".",
"getValue",
"(",
")",
";",
"}"
]
| Edit source code of template
@param {aria.DomEvent} event | [
"Edit",
"source",
"code",
"of",
"template"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/tools/inspector/TemplateInspectorScript.js#L128-L136 | train |
|
ariatemplates/ariatemplates | src/aria/templates/CSSParser.js | function (template, context, statements, throwErrors) {
this.context = context;
// Remove comments
this._prepare(template, throwErrors);
// Preprocess
if (!this.__preprocess(statements, throwErrors)) {
return null;
}
// Compute line numbers
this._computeLineNumbers();
// Build the tree
return this._buildTree(throwErrors);
} | javascript | function (template, context, statements, throwErrors) {
this.context = context;
// Remove comments
this._prepare(template, throwErrors);
// Preprocess
if (!this.__preprocess(statements, throwErrors)) {
return null;
}
// Compute line numbers
this._computeLineNumbers();
// Build the tree
return this._buildTree(throwErrors);
} | [
"function",
"(",
"template",
",",
"context",
",",
"statements",
",",
"throwErrors",
")",
"{",
"this",
".",
"context",
"=",
"context",
";",
"this",
".",
"_prepare",
"(",
"template",
",",
"throwErrors",
")",
";",
"if",
"(",
"!",
"this",
".",
"__preprocess",
"(",
"statements",
",",
"throwErrors",
")",
")",
"{",
"return",
"null",
";",
"}",
"this",
".",
"_computeLineNumbers",
"(",
")",
";",
"return",
"this",
".",
"_buildTree",
"(",
"throwErrors",
")",
";",
"}"
]
| Parse the given CSS template and return a tree representing the template. Overrides aria.templates.Parser to
preprocess the text and escape curly brackets
@param {String} template to parse
@param {Object} context template context data, passes additional information the to error log
@param {Object} statements list of statements allowed by the class generator
@param {Boolean} throwErrors if true, errors will be thrown instead of being logged
@return {aria.templates.TreeBeans:Root} The tree built from the template, or null if an error occured. After
the execution of this method, this.template contains the template with comments and some spaces and removed,
and this.positionToLineNumber can be used to transform positions in this.template into line numbers. | [
"Parse",
"the",
"given",
"CSS",
"template",
"and",
"return",
"a",
"tree",
"representing",
"the",
"template",
".",
"Overrides",
"aria",
".",
"templates",
".",
"Parser",
"to",
"preprocess",
"the",
"text",
"and",
"escape",
"curly",
"brackets"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/templates/CSSParser.js#L44-L56 | train |
|
ariatemplates/ariatemplates | src/aria/templates/CSSParser.js | function (dictionary, throwErrors) {
// Everyting starts on the first {
var text = this.template, utilString = ariaUtilsString, currentPosition = 0, nextOpening = -1, nextClosing = -1, wholeText = [], nameExtractor = /^\{[\s\/]*?([\w]+)\b/, lastCopiedPosition = 0, textLength = text.length, statementLevel = -1, currentLevel = 0, lastOpenedLevel0 = -1;
while (lastCopiedPosition < textLength) {
// Update the pointers
if (nextOpening < currentPosition) {
nextOpening = utilString.indexOfNotEscaped(text, "{", currentPosition);
}
if (nextClosing < currentPosition) {
nextClosing = utilString.indexOfNotEscaped(text, "}", currentPosition);
}
if (nextOpening > -1 && (nextClosing > nextOpening || nextClosing == -1)) {
// found a '{'
if (currentLevel === 0) {
lastOpenedLevel0 = nextOpening;
}
currentLevel++;
if (statementLevel == -1) {
// we are not inside a statement
if (text.charAt(nextOpening - 1) == "$") {
// we do not prefix in case we have ${...}
statementLevel = currentLevel;
} else {
var tag = text.substring(nextOpening, nextClosing);
var currentTagName = nameExtractor.exec(tag);
if (currentTagName && dictionary[currentTagName[1]]) {
// It's a statement, it shouldn't be escaped
// and we should skip everything inside this statement
statementLevel = currentLevel;
} else {
// add a prefix
wholeText.push(text.substring(lastCopiedPosition, nextOpening));
wholeText.push('\\{');
lastCopiedPosition = nextOpening + 1;
}
}
}
currentPosition = nextOpening + 1;
} else if (nextClosing > -1) {
// found '}'
if (currentLevel === 0) {
// missing opening '{' corresponding to '}'
this._computeLineNumbers();
this.logOrThrowError(this.MISSING_OPENINGBRACES, [this.positionToLineNumber(nextClosing)], this.context, throwErrors);
return false;
}
if (statementLevel == currentLevel) {
statementLevel = -1; // no longer inside a statement
} else if (statementLevel == -1) {
// add the prefix for the closing }
wholeText.push(text.substring(lastCopiedPosition, nextClosing));
wholeText.push('\\}');
lastCopiedPosition = nextClosing + 1;
}
currentLevel--;
currentPosition = nextClosing + 1;
} else {
this.$assert(94, nextOpening == -1 && nextClosing == -1);
// no more '{' or '}'
currentPosition = textLength;
wholeText.push(text.substring(lastCopiedPosition, textLength));
lastCopiedPosition = textLength;
}
}
if (currentLevel > 0) {
// missing opening '{' corresponding to '}'
this._computeLineNumbers();
this.logOrThrowError(this.MISSING_CLOSINGBRACES, [this.positionToLineNumber(lastOpenedLevel0)], this.context, throwErrors);
return false;
}
this.template = wholeText.join("");
return true;
} | javascript | function (dictionary, throwErrors) {
// Everyting starts on the first {
var text = this.template, utilString = ariaUtilsString, currentPosition = 0, nextOpening = -1, nextClosing = -1, wholeText = [], nameExtractor = /^\{[\s\/]*?([\w]+)\b/, lastCopiedPosition = 0, textLength = text.length, statementLevel = -1, currentLevel = 0, lastOpenedLevel0 = -1;
while (lastCopiedPosition < textLength) {
// Update the pointers
if (nextOpening < currentPosition) {
nextOpening = utilString.indexOfNotEscaped(text, "{", currentPosition);
}
if (nextClosing < currentPosition) {
nextClosing = utilString.indexOfNotEscaped(text, "}", currentPosition);
}
if (nextOpening > -1 && (nextClosing > nextOpening || nextClosing == -1)) {
// found a '{'
if (currentLevel === 0) {
lastOpenedLevel0 = nextOpening;
}
currentLevel++;
if (statementLevel == -1) {
// we are not inside a statement
if (text.charAt(nextOpening - 1) == "$") {
// we do not prefix in case we have ${...}
statementLevel = currentLevel;
} else {
var tag = text.substring(nextOpening, nextClosing);
var currentTagName = nameExtractor.exec(tag);
if (currentTagName && dictionary[currentTagName[1]]) {
// It's a statement, it shouldn't be escaped
// and we should skip everything inside this statement
statementLevel = currentLevel;
} else {
// add a prefix
wholeText.push(text.substring(lastCopiedPosition, nextOpening));
wholeText.push('\\{');
lastCopiedPosition = nextOpening + 1;
}
}
}
currentPosition = nextOpening + 1;
} else if (nextClosing > -1) {
// found '}'
if (currentLevel === 0) {
// missing opening '{' corresponding to '}'
this._computeLineNumbers();
this.logOrThrowError(this.MISSING_OPENINGBRACES, [this.positionToLineNumber(nextClosing)], this.context, throwErrors);
return false;
}
if (statementLevel == currentLevel) {
statementLevel = -1; // no longer inside a statement
} else if (statementLevel == -1) {
// add the prefix for the closing }
wholeText.push(text.substring(lastCopiedPosition, nextClosing));
wholeText.push('\\}');
lastCopiedPosition = nextClosing + 1;
}
currentLevel--;
currentPosition = nextClosing + 1;
} else {
this.$assert(94, nextOpening == -1 && nextClosing == -1);
// no more '{' or '}'
currentPosition = textLength;
wholeText.push(text.substring(lastCopiedPosition, textLength));
lastCopiedPosition = textLength;
}
}
if (currentLevel > 0) {
// missing opening '{' corresponding to '}'
this._computeLineNumbers();
this.logOrThrowError(this.MISSING_CLOSINGBRACES, [this.positionToLineNumber(lastOpenedLevel0)], this.context, throwErrors);
return false;
}
this.template = wholeText.join("");
return true;
} | [
"function",
"(",
"dictionary",
",",
"throwErrors",
")",
"{",
"var",
"text",
"=",
"this",
".",
"template",
",",
"utilString",
"=",
"ariaUtilsString",
",",
"currentPosition",
"=",
"0",
",",
"nextOpening",
"=",
"-",
"1",
",",
"nextClosing",
"=",
"-",
"1",
",",
"wholeText",
"=",
"[",
"]",
",",
"nameExtractor",
"=",
"/",
"^\\{[\\s\\/]*?([\\w]+)\\b",
"/",
",",
"lastCopiedPosition",
"=",
"0",
",",
"textLength",
"=",
"text",
".",
"length",
",",
"statementLevel",
"=",
"-",
"1",
",",
"currentLevel",
"=",
"0",
",",
"lastOpenedLevel0",
"=",
"-",
"1",
";",
"while",
"(",
"lastCopiedPosition",
"<",
"textLength",
")",
"{",
"if",
"(",
"nextOpening",
"<",
"currentPosition",
")",
"{",
"nextOpening",
"=",
"utilString",
".",
"indexOfNotEscaped",
"(",
"text",
",",
"\"{\"",
",",
"currentPosition",
")",
";",
"}",
"if",
"(",
"nextClosing",
"<",
"currentPosition",
")",
"{",
"nextClosing",
"=",
"utilString",
".",
"indexOfNotEscaped",
"(",
"text",
",",
"\"}\"",
",",
"currentPosition",
")",
";",
"}",
"if",
"(",
"nextOpening",
">",
"-",
"1",
"&&",
"(",
"nextClosing",
">",
"nextOpening",
"||",
"nextClosing",
"==",
"-",
"1",
")",
")",
"{",
"if",
"(",
"currentLevel",
"===",
"0",
")",
"{",
"lastOpenedLevel0",
"=",
"nextOpening",
";",
"}",
"currentLevel",
"++",
";",
"if",
"(",
"statementLevel",
"==",
"-",
"1",
")",
"{",
"if",
"(",
"text",
".",
"charAt",
"(",
"nextOpening",
"-",
"1",
")",
"==",
"\"$\"",
")",
"{",
"statementLevel",
"=",
"currentLevel",
";",
"}",
"else",
"{",
"var",
"tag",
"=",
"text",
".",
"substring",
"(",
"nextOpening",
",",
"nextClosing",
")",
";",
"var",
"currentTagName",
"=",
"nameExtractor",
".",
"exec",
"(",
"tag",
")",
";",
"if",
"(",
"currentTagName",
"&&",
"dictionary",
"[",
"currentTagName",
"[",
"1",
"]",
"]",
")",
"{",
"statementLevel",
"=",
"currentLevel",
";",
"}",
"else",
"{",
"wholeText",
".",
"push",
"(",
"text",
".",
"substring",
"(",
"lastCopiedPosition",
",",
"nextOpening",
")",
")",
";",
"wholeText",
".",
"push",
"(",
"'\\\\{'",
")",
";",
"\\\\",
"}",
"}",
"}",
"lastCopiedPosition",
"=",
"nextOpening",
"+",
"1",
";",
"}",
"else",
"currentPosition",
"=",
"nextOpening",
"+",
"1",
";",
"}",
"if",
"(",
"nextClosing",
">",
"-",
"1",
")",
"{",
"if",
"(",
"currentLevel",
"===",
"0",
")",
"{",
"this",
".",
"_computeLineNumbers",
"(",
")",
";",
"this",
".",
"logOrThrowError",
"(",
"this",
".",
"MISSING_OPENINGBRACES",
",",
"[",
"this",
".",
"positionToLineNumber",
"(",
"nextClosing",
")",
"]",
",",
"this",
".",
"context",
",",
"throwErrors",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"statementLevel",
"==",
"currentLevel",
")",
"{",
"statementLevel",
"=",
"-",
"1",
";",
"}",
"else",
"if",
"(",
"statementLevel",
"==",
"-",
"1",
")",
"{",
"wholeText",
".",
"push",
"(",
"text",
".",
"substring",
"(",
"lastCopiedPosition",
",",
"nextClosing",
")",
")",
";",
"wholeText",
".",
"push",
"(",
"'\\\\}'",
")",
";",
"\\\\",
"}",
"lastCopiedPosition",
"=",
"nextClosing",
"+",
"1",
";",
"currentLevel",
"--",
";",
"}",
"else",
"currentPosition",
"=",
"nextClosing",
"+",
"1",
";",
"{",
"this",
".",
"$assert",
"(",
"94",
",",
"nextOpening",
"==",
"-",
"1",
"&&",
"nextClosing",
"==",
"-",
"1",
")",
";",
"currentPosition",
"=",
"textLength",
";",
"wholeText",
".",
"push",
"(",
"text",
".",
"substring",
"(",
"lastCopiedPosition",
",",
"textLength",
")",
")",
";",
"lastCopiedPosition",
"=",
"textLength",
";",
"}",
"if",
"(",
"currentLevel",
">",
"0",
")",
"{",
"this",
".",
"_computeLineNumbers",
"(",
")",
";",
"this",
".",
"logOrThrowError",
"(",
"this",
".",
"MISSING_CLOSINGBRACES",
",",
"[",
"this",
".",
"positionToLineNumber",
"(",
"lastOpenedLevel0",
")",
"]",
",",
"this",
".",
"context",
",",
"throwErrors",
")",
";",
"return",
"false",
";",
"}",
"}"
]
| Preprocess the CSS template to escape any curly brackets that will break the tree build
@param {Object} dictionary list of statementes allowed by the class generator
@return {Boolean} true if preprocessing was done successfully or false if there was a mismatch between '{'
and '}'
@private | [
"Preprocess",
"the",
"CSS",
"template",
"to",
"escape",
"any",
"curly",
"brackets",
"that",
"will",
"break",
"the",
"tree",
"build"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/templates/CSSParser.js#L65-L139 | train |
|
ariatemplates/ariatemplates | src/aria/touch/widgets/Button.js | function (event) {
if (event.type == "tapstart") {
this.timerId = ariaCoreTimer.addCallback({
fn : this._delayedHighlightCB,
scope : this,
delay : this._timeDelay
});
}
if (event.type == "tapcancel" || event.type == "tap") {
if (this.timerId) {
ariaCoreTimer.cancelCallback(this.timerId);
this.timerId = null;
}
if (event.type == "tapcancel" || (event.type == "tap" && !this._isLink)) {
this._classList.remove("touchLibButtonPressed");
}
}
} | javascript | function (event) {
if (event.type == "tapstart") {
this.timerId = ariaCoreTimer.addCallback({
fn : this._delayedHighlightCB,
scope : this,
delay : this._timeDelay
});
}
if (event.type == "tapcancel" || event.type == "tap") {
if (this.timerId) {
ariaCoreTimer.cancelCallback(this.timerId);
this.timerId = null;
}
if (event.type == "tapcancel" || (event.type == "tap" && !this._isLink)) {
this._classList.remove("touchLibButtonPressed");
}
}
} | [
"function",
"(",
"event",
")",
"{",
"if",
"(",
"event",
".",
"type",
"==",
"\"tapstart\"",
")",
"{",
"this",
".",
"timerId",
"=",
"ariaCoreTimer",
".",
"addCallback",
"(",
"{",
"fn",
":",
"this",
".",
"_delayedHighlightCB",
",",
"scope",
":",
"this",
",",
"delay",
":",
"this",
".",
"_timeDelay",
"}",
")",
";",
"}",
"if",
"(",
"event",
".",
"type",
"==",
"\"tapcancel\"",
"||",
"event",
".",
"type",
"==",
"\"tap\"",
")",
"{",
"if",
"(",
"this",
".",
"timerId",
")",
"{",
"ariaCoreTimer",
".",
"cancelCallback",
"(",
"this",
".",
"timerId",
")",
";",
"this",
".",
"timerId",
"=",
"null",
";",
"}",
"if",
"(",
"event",
".",
"type",
"==",
"\"tapcancel\"",
"||",
"(",
"event",
".",
"type",
"==",
"\"tap\"",
"&&",
"!",
"this",
".",
"_isLink",
")",
")",
"{",
"this",
".",
"_classList",
".",
"remove",
"(",
"\"touchLibButtonPressed\"",
")",
";",
"}",
"}",
"}"
]
| Manage the touch events defined by the widget itself
@param {HTMLEvent} event Native event | [
"Manage",
"the",
"touch",
"events",
"defined",
"by",
"the",
"widget",
"itself"
]
| 7ed5d065818ae159bf361c9dfb209b1cf3883c90 | https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/touch/widgets/Button.js#L132-L150 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.