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/widgets/form/list/List.js
|
function (eventOrCharCode, keyCode) {
// -------------------------------------- input arguments processing
var event;
var charCode;
if (ariaUtilsType.isObject(eventOrCharCode)) {
event = eventOrCharCode;
charCode = event.charCode;
keyCode = event.keyCode;
} else {
event = null;
charCode = eventOrCharCode;
}
// ------------------------------------------------------ processing
var moduleCtrl = this._subTplModuleCtrl;
var closeItem = this._getFirstEnabledItem();
if (moduleCtrl) {
var data = moduleCtrl.getData();
if (!this.evalCallback(this._cfg.onkeyevent, {
charCode : charCode,
keyCode : keyCode,
focusIndex : data.focusIndex,
closeItem : closeItem,
event : event
})) {
return moduleCtrl.keyevent({
charCode : charCode,
keyCode : keyCode
});
} else {
return true;
}
}
return false;
}
|
javascript
|
function (eventOrCharCode, keyCode) {
// -------------------------------------- input arguments processing
var event;
var charCode;
if (ariaUtilsType.isObject(eventOrCharCode)) {
event = eventOrCharCode;
charCode = event.charCode;
keyCode = event.keyCode;
} else {
event = null;
charCode = eventOrCharCode;
}
// ------------------------------------------------------ processing
var moduleCtrl = this._subTplModuleCtrl;
var closeItem = this._getFirstEnabledItem();
if (moduleCtrl) {
var data = moduleCtrl.getData();
if (!this.evalCallback(this._cfg.onkeyevent, {
charCode : charCode,
keyCode : keyCode,
focusIndex : data.focusIndex,
closeItem : closeItem,
event : event
})) {
return moduleCtrl.keyevent({
charCode : charCode,
keyCode : keyCode
});
} else {
return true;
}
}
return false;
}
|
[
"function",
"(",
"eventOrCharCode",
",",
"keyCode",
")",
"{",
"var",
"event",
";",
"var",
"charCode",
";",
"if",
"(",
"ariaUtilsType",
".",
"isObject",
"(",
"eventOrCharCode",
")",
")",
"{",
"event",
"=",
"eventOrCharCode",
";",
"charCode",
"=",
"event",
".",
"charCode",
";",
"keyCode",
"=",
"event",
".",
"keyCode",
";",
"}",
"else",
"{",
"event",
"=",
"null",
";",
"charCode",
"=",
"eventOrCharCode",
";",
"}",
"var",
"moduleCtrl",
"=",
"this",
".",
"_subTplModuleCtrl",
";",
"var",
"closeItem",
"=",
"this",
".",
"_getFirstEnabledItem",
"(",
")",
";",
"if",
"(",
"moduleCtrl",
")",
"{",
"var",
"data",
"=",
"moduleCtrl",
".",
"getData",
"(",
")",
";",
"if",
"(",
"!",
"this",
".",
"evalCallback",
"(",
"this",
".",
"_cfg",
".",
"onkeyevent",
",",
"{",
"charCode",
":",
"charCode",
",",
"keyCode",
":",
"keyCode",
",",
"focusIndex",
":",
"data",
".",
"focusIndex",
",",
"closeItem",
":",
"closeItem",
",",
"event",
":",
"event",
"}",
")",
")",
"{",
"return",
"moduleCtrl",
".",
"keyevent",
"(",
"{",
"charCode",
":",
"charCode",
",",
"keyCode",
":",
"keyCode",
"}",
")",
";",
"}",
"else",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Return true to cancel default action.
@param {aria.DomEvent|Number} eventOrCharCode Original event or character code directly
@param {Number} keyCode Ignored if the original event has been passed, otherwise the code of the button pressed
@return {Boolean}
|
[
"Return",
"true",
"to",
"cancel",
"default",
"action",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/list/List.js#L98-L139
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/form/list/List.js
|
function (event) {
if (this._subTplModuleCtrl) {
if (!event.isSpecialKey && event.charCode != event.KC_SPACE) {
this.sendKey(event);
}
}
}
|
javascript
|
function (event) {
if (this._subTplModuleCtrl) {
if (!event.isSpecialKey && event.charCode != event.KC_SPACE) {
this.sendKey(event);
}
}
}
|
[
"function",
"(",
"event",
")",
"{",
"if",
"(",
"this",
".",
"_subTplModuleCtrl",
")",
"{",
"if",
"(",
"!",
"event",
".",
"isSpecialKey",
"&&",
"event",
".",
"charCode",
"!=",
"event",
".",
"KC_SPACE",
")",
"{",
"this",
".",
"sendKey",
"(",
"event",
")",
";",
"}",
"}",
"}"
] |
DOM callback function called on key press
|
[
"DOM",
"callback",
"function",
"called",
"on",
"key",
"press"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/list/List.js#L207-L213
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/form/list/List.js
|
function (event) {
// event.cancelBubble = true;
if (this._subTplModuleCtrl) {
if (event.isSpecialKey) {
this.sendKey(event);
}
}
if (event.keyCode != event.KC_TAB) {
event.preventDefault(); // Removing due to PTR:05164409
}
return false;
}
|
javascript
|
function (event) {
// event.cancelBubble = true;
if (this._subTplModuleCtrl) {
if (event.isSpecialKey) {
this.sendKey(event);
}
}
if (event.keyCode != event.KC_TAB) {
event.preventDefault(); // Removing due to PTR:05164409
}
return false;
}
|
[
"function",
"(",
"event",
")",
"{",
"if",
"(",
"this",
".",
"_subTplModuleCtrl",
")",
"{",
"if",
"(",
"event",
".",
"isSpecialKey",
")",
"{",
"this",
".",
"sendKey",
"(",
"event",
")",
";",
"}",
"}",
"if",
"(",
"event",
".",
"keyCode",
"!=",
"event",
".",
"KC_TAB",
")",
"{",
"event",
".",
"preventDefault",
"(",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
DOM callback function called on key down
|
[
"DOM",
"callback",
"function",
"called",
"on",
"key",
"down"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/list/List.js#L228-L239
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/form/list/List.js
|
function () {
var data = this._subTplModuleCtrl.getData();
var toFocus = data.itemsView.items[data.focusIndex].initIndex;
if (data.items[toFocus].currentlyDisabled) {
data.focusIndex = this._getFirstEnabledItem().id;
}
this._subTplModuleCtrl.setFocus();
}
|
javascript
|
function () {
var data = this._subTplModuleCtrl.getData();
var toFocus = data.itemsView.items[data.focusIndex].initIndex;
if (data.items[toFocus].currentlyDisabled) {
data.focusIndex = this._getFirstEnabledItem().id;
}
this._subTplModuleCtrl.setFocus();
}
|
[
"function",
"(",
")",
"{",
"var",
"data",
"=",
"this",
".",
"_subTplModuleCtrl",
".",
"getData",
"(",
")",
";",
"var",
"toFocus",
"=",
"data",
".",
"itemsView",
".",
"items",
"[",
"data",
".",
"focusIndex",
"]",
".",
"initIndex",
";",
"if",
"(",
"data",
".",
"items",
"[",
"toFocus",
"]",
".",
"currentlyDisabled",
")",
"{",
"data",
".",
"focusIndex",
"=",
"this",
".",
"_getFirstEnabledItem",
"(",
")",
".",
"id",
";",
"}",
"this",
".",
"_subTplModuleCtrl",
".",
"setFocus",
"(",
")",
";",
"}"
] |
DOM callback function called on focus
|
[
"DOM",
"callback",
"function",
"called",
"on",
"focus"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/list/List.js#L244-L251
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/form/list/List.js
|
function (key, newValue, oldValue) {
// If the template needs a refresh, refreshNeeded has to be set to true
// by each of the updates below that needs a refresh
var refreshNeeded = false;
var moduleCtrl = this._subTplModuleCtrl;
// var data = this._subTplCtxt.data;
if (key == "selectedValues") {
moduleCtrl.setSelectedValues(newValue);
} else if (key == "selectedIndex") {
moduleCtrl.setSelectedIndex(newValue);
} else if (key == "disabled") {
moduleCtrl.setDisabled(newValue);
refreshNeeded = true;
} else if (key == "maxOptions") {
moduleCtrl.setMaxSelectedCount(newValue);
} else if (key == "items") {
moduleCtrl.setItems(newValue);
refreshNeeded = true;
this._retrieveControllerSelection();
} else if (key == "multipleSelect") {
moduleCtrl.setMultipleSelect(newValue);
}
if (refreshNeeded) {
// TODO: this should be replaced by an event sent from the module controller
// (but this would not be backward-compatible with current list templates)
this._subTplCtxt.$refresh();
}
}
|
javascript
|
function (key, newValue, oldValue) {
// If the template needs a refresh, refreshNeeded has to be set to true
// by each of the updates below that needs a refresh
var refreshNeeded = false;
var moduleCtrl = this._subTplModuleCtrl;
// var data = this._subTplCtxt.data;
if (key == "selectedValues") {
moduleCtrl.setSelectedValues(newValue);
} else if (key == "selectedIndex") {
moduleCtrl.setSelectedIndex(newValue);
} else if (key == "disabled") {
moduleCtrl.setDisabled(newValue);
refreshNeeded = true;
} else if (key == "maxOptions") {
moduleCtrl.setMaxSelectedCount(newValue);
} else if (key == "items") {
moduleCtrl.setItems(newValue);
refreshNeeded = true;
this._retrieveControllerSelection();
} else if (key == "multipleSelect") {
moduleCtrl.setMultipleSelect(newValue);
}
if (refreshNeeded) {
// TODO: this should be replaced by an event sent from the module controller
// (but this would not be backward-compatible with current list templates)
this._subTplCtxt.$refresh();
}
}
|
[
"function",
"(",
"key",
",",
"newValue",
",",
"oldValue",
")",
"{",
"var",
"refreshNeeded",
"=",
"false",
";",
"var",
"moduleCtrl",
"=",
"this",
".",
"_subTplModuleCtrl",
";",
"if",
"(",
"key",
"==",
"\"selectedValues\"",
")",
"{",
"moduleCtrl",
".",
"setSelectedValues",
"(",
"newValue",
")",
";",
"}",
"else",
"if",
"(",
"key",
"==",
"\"selectedIndex\"",
")",
"{",
"moduleCtrl",
".",
"setSelectedIndex",
"(",
"newValue",
")",
";",
"}",
"else",
"if",
"(",
"key",
"==",
"\"disabled\"",
")",
"{",
"moduleCtrl",
".",
"setDisabled",
"(",
"newValue",
")",
";",
"refreshNeeded",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"key",
"==",
"\"maxOptions\"",
")",
"{",
"moduleCtrl",
".",
"setMaxSelectedCount",
"(",
"newValue",
")",
";",
"}",
"else",
"if",
"(",
"key",
"==",
"\"items\"",
")",
"{",
"moduleCtrl",
".",
"setItems",
"(",
"newValue",
")",
";",
"refreshNeeded",
"=",
"true",
";",
"this",
".",
"_retrieveControllerSelection",
"(",
")",
";",
"}",
"else",
"if",
"(",
"key",
"==",
"\"multipleSelect\"",
")",
"{",
"moduleCtrl",
".",
"setMultipleSelect",
"(",
"newValue",
")",
";",
"}",
"if",
"(",
"refreshNeeded",
")",
"{",
"this",
".",
"_subTplCtxt",
".",
"$refresh",
"(",
")",
";",
"}",
"}"
] |
Called when json data that we have properties bound to are externally changed. In general we need to update
our internal data model and refresh the sub template if needed.
@param {String} key The property changed
@param {Object} newValue
@param {Object} oldValue
|
[
"Called",
"when",
"json",
"data",
"that",
"we",
"have",
"properties",
"bound",
"to",
"are",
"externally",
"changed",
".",
"In",
"general",
"we",
"need",
"to",
"update",
"our",
"internal",
"data",
"model",
"and",
"refresh",
"the",
"sub",
"template",
"if",
"needed",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/list/List.js#L260-L287
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/form/list/List.js
|
function (property) {
var bindings = this._cfg.bind, bind = bindings[property];
if (bindings && bind && bindings.hasOwnProperty(property) && property === "items") {
var callback = {
fn : this._notifyDataChange,
scope : this,
args : property
};
try {
ariaUtilsJson.addListener(bind.inside, bind.to, callback, true, true);
this._bindingListeners[property] = {
inside : bind.inside,
to : bind.to,
transform : bind.transform,
cb : callback
};
var newValue = this._transform(bind.transform, bind.inside[bind.to], "toWidget");
this._cfg[property] = newValue;
} catch (ex) {
this.$logError(this.INVALID_BEAN, [property, "bind"]);
}
} else {
this.$TemplateBasedWidget._registerSingleProperty.apply(this, arguments);
}
}
|
javascript
|
function (property) {
var bindings = this._cfg.bind, bind = bindings[property];
if (bindings && bind && bindings.hasOwnProperty(property) && property === "items") {
var callback = {
fn : this._notifyDataChange,
scope : this,
args : property
};
try {
ariaUtilsJson.addListener(bind.inside, bind.to, callback, true, true);
this._bindingListeners[property] = {
inside : bind.inside,
to : bind.to,
transform : bind.transform,
cb : callback
};
var newValue = this._transform(bind.transform, bind.inside[bind.to], "toWidget");
this._cfg[property] = newValue;
} catch (ex) {
this.$logError(this.INVALID_BEAN, [property, "bind"]);
}
} else {
this.$TemplateBasedWidget._registerSingleProperty.apply(this, arguments);
}
}
|
[
"function",
"(",
"property",
")",
"{",
"var",
"bindings",
"=",
"this",
".",
"_cfg",
".",
"bind",
",",
"bind",
"=",
"bindings",
"[",
"property",
"]",
";",
"if",
"(",
"bindings",
"&&",
"bind",
"&&",
"bindings",
".",
"hasOwnProperty",
"(",
"property",
")",
"&&",
"property",
"===",
"\"items\"",
")",
"{",
"var",
"callback",
"=",
"{",
"fn",
":",
"this",
".",
"_notifyDataChange",
",",
"scope",
":",
"this",
",",
"args",
":",
"property",
"}",
";",
"try",
"{",
"ariaUtilsJson",
".",
"addListener",
"(",
"bind",
".",
"inside",
",",
"bind",
".",
"to",
",",
"callback",
",",
"true",
",",
"true",
")",
";",
"this",
".",
"_bindingListeners",
"[",
"property",
"]",
"=",
"{",
"inside",
":",
"bind",
".",
"inside",
",",
"to",
":",
"bind",
".",
"to",
",",
"transform",
":",
"bind",
".",
"transform",
",",
"cb",
":",
"callback",
"}",
";",
"var",
"newValue",
"=",
"this",
".",
"_transform",
"(",
"bind",
".",
"transform",
",",
"bind",
".",
"inside",
"[",
"bind",
".",
"to",
"]",
",",
"\"toWidget\"",
")",
";",
"this",
".",
"_cfg",
"[",
"property",
"]",
"=",
"newValue",
";",
"}",
"catch",
"(",
"ex",
")",
"{",
"this",
".",
"$logError",
"(",
"this",
".",
"INVALID_BEAN",
",",
"[",
"property",
",",
"\"bind\"",
"]",
")",
";",
"}",
"}",
"else",
"{",
"this",
".",
"$TemplateBasedWidget",
".",
"_registerSingleProperty",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"}",
"}"
] |
Register listeners for the bindings associated to this widget
@protected
|
[
"Register",
"listeners",
"for",
"the",
"bindings",
"associated",
"to",
"this",
"widget"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/list/List.js#L293-L319
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/form/list/List.js
|
function (propertyName, newValue) {
if (!this._cfg) {
return;
}
if (propertyName === "items" && this._cfg.bind.hasOwnProperty(propertyName)) {
var oldValue = this.getProperty(propertyName);
this._cfg[propertyName] = newValue;
this._onBoundPropertyChange(propertyName, newValue, oldValue);
} else {
this.$TemplateBasedWidget.setWidgetProperty.apply(this, arguments);
}
}
|
javascript
|
function (propertyName, newValue) {
if (!this._cfg) {
return;
}
if (propertyName === "items" && this._cfg.bind.hasOwnProperty(propertyName)) {
var oldValue = this.getProperty(propertyName);
this._cfg[propertyName] = newValue;
this._onBoundPropertyChange(propertyName, newValue, oldValue);
} else {
this.$TemplateBasedWidget.setWidgetProperty.apply(this, arguments);
}
}
|
[
"function",
"(",
"propertyName",
",",
"newValue",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_cfg",
")",
"{",
"return",
";",
"}",
"if",
"(",
"propertyName",
"===",
"\"items\"",
"&&",
"this",
".",
"_cfg",
".",
"bind",
".",
"hasOwnProperty",
"(",
"propertyName",
")",
")",
"{",
"var",
"oldValue",
"=",
"this",
".",
"getProperty",
"(",
"propertyName",
")",
";",
"this",
".",
"_cfg",
"[",
"propertyName",
"]",
"=",
"newValue",
";",
"this",
".",
"_onBoundPropertyChange",
"(",
"propertyName",
",",
"newValue",
",",
"oldValue",
")",
";",
"}",
"else",
"{",
"this",
".",
"$TemplateBasedWidget",
".",
"setWidgetProperty",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"}",
"}"
] |
Set property for this widget, and reflect change on itself, but not in the associated datamodel
@param {String} propertyName in the configuration
@param {Object} newValue to set
|
[
"Set",
"property",
"for",
"this",
"widget",
"and",
"reflect",
"change",
"on",
"itself",
"but",
"not",
"in",
"the",
"associated",
"datamodel"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/list/List.js#L326-L337
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/form/list/List.js
|
function (optionIndex) {
if (this._subTplCtxt) {
var data = this._subTplModuleCtrl.getData();
if (data.waiAria && optionIndex > -1 && optionIndex < data.items.length) {
return this._subTplCtxt.$getId(data.listItemDomIdPrefix + optionIndex);
}
}
}
|
javascript
|
function (optionIndex) {
if (this._subTplCtxt) {
var data = this._subTplModuleCtrl.getData();
if (data.waiAria && optionIndex > -1 && optionIndex < data.items.length) {
return this._subTplCtxt.$getId(data.listItemDomIdPrefix + optionIndex);
}
}
}
|
[
"function",
"(",
"optionIndex",
")",
"{",
"if",
"(",
"this",
".",
"_subTplCtxt",
")",
"{",
"var",
"data",
"=",
"this",
".",
"_subTplModuleCtrl",
".",
"getData",
"(",
")",
";",
"if",
"(",
"data",
".",
"waiAria",
"&&",
"optionIndex",
">",
"-",
"1",
"&&",
"optionIndex",
"<",
"data",
".",
"items",
".",
"length",
")",
"{",
"return",
"this",
".",
"_subTplCtxt",
".",
"$getId",
"(",
"data",
".",
"listItemDomIdPrefix",
"+",
"optionIndex",
")",
";",
"}",
"}",
"}"
] |
Returns the id of the DOM element corresponding to the item in the list at the given index.
This method only works if accessibility was enabled at the time the list widget was created.
@param {Integer} optionIndex index of the item whose id should be returned
@return {String} id of the DOM element or undefined if the list is not fully loaded yet, accessibility
is disabled or the index is invalid
|
[
"Returns",
"the",
"id",
"of",
"the",
"DOM",
"element",
"corresponding",
"to",
"the",
"item",
"in",
"the",
"list",
"at",
"the",
"given",
"index",
".",
"This",
"method",
"only",
"works",
"if",
"accessibility",
"was",
"enabled",
"at",
"the",
"time",
"the",
"list",
"widget",
"was",
"created",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/list/List.js#L354-L361
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/utils/HashManager.js
|
function (cb) {
var hcC = this._hashChangeCallbacks;
if (hcC != null) {
var len = hcC.length, i = 0;
while (i < len && hcC[i] != cb) {
i++;
}
if (i < len) {
hcC.splice(i, 1);
if (hcC.length === 0) {
this._hashChangeCallbacks = null;
this._removeHashChangeInternalCallback();
}
}
}
}
|
javascript
|
function (cb) {
var hcC = this._hashChangeCallbacks;
if (hcC != null) {
var len = hcC.length, i = 0;
while (i < len && hcC[i] != cb) {
i++;
}
if (i < len) {
hcC.splice(i, 1);
if (hcC.length === 0) {
this._hashChangeCallbacks = null;
this._removeHashChangeInternalCallback();
}
}
}
}
|
[
"function",
"(",
"cb",
")",
"{",
"var",
"hcC",
"=",
"this",
".",
"_hashChangeCallbacks",
";",
"if",
"(",
"hcC",
"!=",
"null",
")",
"{",
"var",
"len",
"=",
"hcC",
".",
"length",
",",
"i",
"=",
"0",
";",
"while",
"(",
"i",
"<",
"len",
"&&",
"hcC",
"[",
"i",
"]",
"!=",
"cb",
")",
"{",
"i",
"++",
";",
"}",
"if",
"(",
"i",
"<",
"len",
")",
"{",
"hcC",
".",
"splice",
"(",
"i",
",",
"1",
")",
";",
"if",
"(",
"hcC",
".",
"length",
"===",
"0",
")",
"{",
"this",
".",
"_hashChangeCallbacks",
"=",
"null",
";",
"this",
".",
"_removeHashChangeInternalCallback",
"(",
")",
";",
"}",
"}",
"}",
"}"
] |
Remove a callback to hashchange event
@param {aria.core.CfgBeans:Callback} cb
|
[
"Remove",
"a",
"callback",
"to",
"hashchange",
"event"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/HashManager.js#L249-L264
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/utils/HashManager.js
|
function (hashObject) {
var hashStringArray = [];
for (var key in hashObject) {
if (hashObject.hasOwnProperty(key)) {
hashStringArray.push(encodeURIComponent(key) + "=" + encodeURIComponent(hashObject[key]));
}
}
return hashStringArray.join(this._separators[0]);
}
|
javascript
|
function (hashObject) {
var hashStringArray = [];
for (var key in hashObject) {
if (hashObject.hasOwnProperty(key)) {
hashStringArray.push(encodeURIComponent(key) + "=" + encodeURIComponent(hashObject[key]));
}
}
return hashStringArray.join(this._separators[0]);
}
|
[
"function",
"(",
"hashObject",
")",
"{",
"var",
"hashStringArray",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"key",
"in",
"hashObject",
")",
"{",
"if",
"(",
"hashObject",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"hashStringArray",
".",
"push",
"(",
"encodeURIComponent",
"(",
"key",
")",
"+",
"\"=\"",
"+",
"encodeURIComponent",
"(",
"hashObject",
"[",
"key",
"]",
")",
")",
";",
"}",
"}",
"return",
"hashStringArray",
".",
"join",
"(",
"this",
".",
"_separators",
"[",
"0",
"]",
")",
";",
"}"
] |
Turn a hash object into a string by using as separator the first one provided. There is no check on the
object.
@param {Object} hashObject
@return {String}
|
[
"Turn",
"a",
"hash",
"object",
"into",
"a",
"string",
"by",
"using",
"as",
"separator",
"the",
"first",
"one",
"provided",
".",
"There",
"is",
"no",
"check",
"on",
"the",
"object",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/HashManager.js#L346-L354
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/utils/HashManager.js
|
function (hashString) {
var pairs = hashString, hashObject = {}, currentPair, currentPairString;
pairs = (pairs) ? pairs.split(this._separatorRegExp) : [];
for (var i = 0, size = pairs.length; size > i; i++) {
currentPairString = pairs[i];
currentPair = decodeURIComponent(currentPairString).split("=");
if (currentPair.length == 2) {
hashObject[currentPair[0]] = currentPair[1];
} else {
if (currentPairString.indexOf("=") == currentPairString.length) {
hashObject[currentPair[0]] = "";
} else {
hashObject["param" + i] = currentPair[0];
}
}
}
return hashObject;
}
|
javascript
|
function (hashString) {
var pairs = hashString, hashObject = {}, currentPair, currentPairString;
pairs = (pairs) ? pairs.split(this._separatorRegExp) : [];
for (var i = 0, size = pairs.length; size > i; i++) {
currentPairString = pairs[i];
currentPair = decodeURIComponent(currentPairString).split("=");
if (currentPair.length == 2) {
hashObject[currentPair[0]] = currentPair[1];
} else {
if (currentPairString.indexOf("=") == currentPairString.length) {
hashObject[currentPair[0]] = "";
} else {
hashObject["param" + i] = currentPair[0];
}
}
}
return hashObject;
}
|
[
"function",
"(",
"hashString",
")",
"{",
"var",
"pairs",
"=",
"hashString",
",",
"hashObject",
"=",
"{",
"}",
",",
"currentPair",
",",
"currentPairString",
";",
"pairs",
"=",
"(",
"pairs",
")",
"?",
"pairs",
".",
"split",
"(",
"this",
".",
"_separatorRegExp",
")",
":",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"size",
"=",
"pairs",
".",
"length",
";",
"size",
">",
"i",
";",
"i",
"++",
")",
"{",
"currentPairString",
"=",
"pairs",
"[",
"i",
"]",
";",
"currentPair",
"=",
"decodeURIComponent",
"(",
"currentPairString",
")",
".",
"split",
"(",
"\"=\"",
")",
";",
"if",
"(",
"currentPair",
".",
"length",
"==",
"2",
")",
"{",
"hashObject",
"[",
"currentPair",
"[",
"0",
"]",
"]",
"=",
"currentPair",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"if",
"(",
"currentPairString",
".",
"indexOf",
"(",
"\"=\"",
")",
"==",
"currentPairString",
".",
"length",
")",
"{",
"hashObject",
"[",
"currentPair",
"[",
"0",
"]",
"]",
"=",
"\"\"",
";",
"}",
"else",
"{",
"hashObject",
"[",
"\"param\"",
"+",
"i",
"]",
"=",
"currentPair",
"[",
"0",
"]",
";",
"}",
"}",
"}",
"return",
"hashObject",
";",
"}"
] |
Extract the hash object from the hash string
@protected
@param {String} hashString
@return {Object} hashObject
|
[
"Extract",
"the",
"hash",
"object",
"from",
"the",
"hash",
"string"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/HashManager.js#L362-L379
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/utils/HashManager.js
|
function () {
if (!this._isIE7OrLess) {
this._hashChangeCallbackAdded = true;
ariaUtilsAriaWindow.attachWindow();
ariaUtilsEvent.addListener(Aria.$window, 'hashchange', {
fn : this._internalCallback,
scope : this
}, true);
}
}
|
javascript
|
function () {
if (!this._isIE7OrLess) {
this._hashChangeCallbackAdded = true;
ariaUtilsAriaWindow.attachWindow();
ariaUtilsEvent.addListener(Aria.$window, 'hashchange', {
fn : this._internalCallback,
scope : this
}, true);
}
}
|
[
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_isIE7OrLess",
")",
"{",
"this",
".",
"_hashChangeCallbackAdded",
"=",
"true",
";",
"ariaUtilsAriaWindow",
".",
"attachWindow",
"(",
")",
";",
"ariaUtilsEvent",
".",
"addListener",
"(",
"Aria",
".",
"$window",
",",
"'hashchange'",
",",
"{",
"fn",
":",
"this",
".",
"_internalCallback",
",",
"scope",
":",
"this",
"}",
",",
"true",
")",
";",
"}",
"}"
] |
Add the default hashchange callback
@protected
|
[
"Add",
"the",
"default",
"hashchange",
"callback"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/HashManager.js#L385-L395
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/utils/HashManager.js
|
function () {
if (this._enableIEpolling) {
this._hashPollCallback = ariaCoreTimer.addCallback({
fn : this._hashPoll,
scope : this,
delay : this.ie7PollDelay
});
var documentHash = this.getHashString();
var iframeHash = this.polledIframeHashString;
// back or forward
if (iframeHash != this._currentIframeHashString) {
this._currentIframeHashString = iframeHash;
this._currentHashString = iframeHash;
this.setHash(iframeHash);
this._internalCallback();
} else if (documentHash != this._currentHashString) {// no back or forward
this._addIframeHistoryEntry(documentHash);
this._internalCallback();
}
}
}
|
javascript
|
function () {
if (this._enableIEpolling) {
this._hashPollCallback = ariaCoreTimer.addCallback({
fn : this._hashPoll,
scope : this,
delay : this.ie7PollDelay
});
var documentHash = this.getHashString();
var iframeHash = this.polledIframeHashString;
// back or forward
if (iframeHash != this._currentIframeHashString) {
this._currentIframeHashString = iframeHash;
this._currentHashString = iframeHash;
this.setHash(iframeHash);
this._internalCallback();
} else if (documentHash != this._currentHashString) {// no back or forward
this._addIframeHistoryEntry(documentHash);
this._internalCallback();
}
}
}
|
[
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"_enableIEpolling",
")",
"{",
"this",
".",
"_hashPollCallback",
"=",
"ariaCoreTimer",
".",
"addCallback",
"(",
"{",
"fn",
":",
"this",
".",
"_hashPoll",
",",
"scope",
":",
"this",
",",
"delay",
":",
"this",
".",
"ie7PollDelay",
"}",
")",
";",
"var",
"documentHash",
"=",
"this",
".",
"getHashString",
"(",
")",
";",
"var",
"iframeHash",
"=",
"this",
".",
"polledIframeHashString",
";",
"if",
"(",
"iframeHash",
"!=",
"this",
".",
"_currentIframeHashString",
")",
"{",
"this",
".",
"_currentIframeHashString",
"=",
"iframeHash",
";",
"this",
".",
"_currentHashString",
"=",
"iframeHash",
";",
"this",
".",
"setHash",
"(",
"iframeHash",
")",
";",
"this",
".",
"_internalCallback",
"(",
")",
";",
"}",
"else",
"if",
"(",
"documentHash",
"!=",
"this",
".",
"_currentHashString",
")",
"{",
"this",
".",
"_addIframeHistoryEntry",
"(",
"documentHash",
")",
";",
"this",
".",
"_internalCallback",
"(",
")",
";",
"}",
"}",
"}"
] |
Nedeed because IE7 does not fire the 'hashchange' event. Verify if the hash has changed. If so, it triggers
the internal hashchange callback
@protected
|
[
"Nedeed",
"because",
"IE7",
"does",
"not",
"fire",
"the",
"hashchange",
"event",
".",
"Verify",
"if",
"the",
"hash",
"has",
"changed",
".",
"If",
"so",
"it",
"triggers",
"the",
"internal",
"hashchange",
"callback"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/HashManager.js#L401-L424
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/utils/HashManager.js
|
function () {
var callbacks = this._hashChangeCallbacks, cb;
if (callbacks == null) {
return;
}
this._currentHashString = this.getHashString();
var currentHashObject = this._extractHashObject(this._currentHashString);
for (var i = 0, size = callbacks.length; size > i; i++) {
cb = callbacks[i];
cb = this.$normCallback(cb);
this.$callback(cb, currentHashObject);
}
}
|
javascript
|
function () {
var callbacks = this._hashChangeCallbacks, cb;
if (callbacks == null) {
return;
}
this._currentHashString = this.getHashString();
var currentHashObject = this._extractHashObject(this._currentHashString);
for (var i = 0, size = callbacks.length; size > i; i++) {
cb = callbacks[i];
cb = this.$normCallback(cb);
this.$callback(cb, currentHashObject);
}
}
|
[
"function",
"(",
")",
"{",
"var",
"callbacks",
"=",
"this",
".",
"_hashChangeCallbacks",
",",
"cb",
";",
"if",
"(",
"callbacks",
"==",
"null",
")",
"{",
"return",
";",
"}",
"this",
".",
"_currentHashString",
"=",
"this",
".",
"getHashString",
"(",
")",
";",
"var",
"currentHashObject",
"=",
"this",
".",
"_extractHashObject",
"(",
"this",
".",
"_currentHashString",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"size",
"=",
"callbacks",
".",
"length",
";",
"size",
">",
"i",
";",
"i",
"++",
")",
"{",
"cb",
"=",
"callbacks",
"[",
"i",
"]",
";",
"cb",
"=",
"this",
".",
"$normCallback",
"(",
"cb",
")",
";",
"this",
".",
"$callback",
"(",
"cb",
",",
"currentHashObject",
")",
";",
"}",
"}"
] |
Updates the internal hash information and calls the added callbacks
@protected
|
[
"Updates",
"the",
"internal",
"hash",
"information",
"and",
"calls",
"the",
"added",
"callbacks"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/HashManager.js#L430-L442
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/utils/HashManager.js
|
function () {
if (!this._isIE7OrLess && this._hashChangeCallbackAdded) {
this._hashChangeCallbackAdded = false;
ariaUtilsEvent.removeListener(Aria.$window, 'hashchange', {
fn : this._internalCallback
});
ariaUtilsAriaWindow.detachWindow();
}
}
|
javascript
|
function () {
if (!this._isIE7OrLess && this._hashChangeCallbackAdded) {
this._hashChangeCallbackAdded = false;
ariaUtilsEvent.removeListener(Aria.$window, 'hashchange', {
fn : this._internalCallback
});
ariaUtilsAriaWindow.detachWindow();
}
}
|
[
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_isIE7OrLess",
"&&",
"this",
".",
"_hashChangeCallbackAdded",
")",
"{",
"this",
".",
"_hashChangeCallbackAdded",
"=",
"false",
";",
"ariaUtilsEvent",
".",
"removeListener",
"(",
"Aria",
".",
"$window",
",",
"'hashchange'",
",",
"{",
"fn",
":",
"this",
".",
"_internalCallback",
"}",
")",
";",
"ariaUtilsAriaWindow",
".",
"detachWindow",
"(",
")",
";",
"}",
"}"
] |
Remove the default hashchange callback
@protected
|
[
"Remove",
"the",
"default",
"hashchange",
"callback"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/HashManager.js#L448-L456
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/utils/HashManager.js
|
function (hashObject) {
var prop, re = this._nonEncodableSepRegExp;
for (var key in hashObject) {
if (hashObject.hasOwnProperty(key)) {
if (re && key.match(re)) {
this.$logError(this.INVALID_HASHOBJECT_KEY, [key, this._nonEncodableSeparators.join("")]);
return false;
} else {
prop = hashObject[key];
if (this._typeUtil.isString(prop)) {
if (re && prop.match(re)) {
this.$logError(this.INVALID_HASHOBJECT_VALUE, [prop, key,
this._nonEncodableSeparators.join("")]);
return false;
}
} else {
this.$logError(this.INVALID_HASHOBJECT_TYPE, key);
return false;
}
}
}
}
return true;
}
|
javascript
|
function (hashObject) {
var prop, re = this._nonEncodableSepRegExp;
for (var key in hashObject) {
if (hashObject.hasOwnProperty(key)) {
if (re && key.match(re)) {
this.$logError(this.INVALID_HASHOBJECT_KEY, [key, this._nonEncodableSeparators.join("")]);
return false;
} else {
prop = hashObject[key];
if (this._typeUtil.isString(prop)) {
if (re && prop.match(re)) {
this.$logError(this.INVALID_HASHOBJECT_VALUE, [prop, key,
this._nonEncodableSeparators.join("")]);
return false;
}
} else {
this.$logError(this.INVALID_HASHOBJECT_TYPE, key);
return false;
}
}
}
}
return true;
}
|
[
"function",
"(",
"hashObject",
")",
"{",
"var",
"prop",
",",
"re",
"=",
"this",
".",
"_nonEncodableSepRegExp",
";",
"for",
"(",
"var",
"key",
"in",
"hashObject",
")",
"{",
"if",
"(",
"hashObject",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"if",
"(",
"re",
"&&",
"key",
".",
"match",
"(",
"re",
")",
")",
"{",
"this",
".",
"$logError",
"(",
"this",
".",
"INVALID_HASHOBJECT_KEY",
",",
"[",
"key",
",",
"this",
".",
"_nonEncodableSeparators",
".",
"join",
"(",
"\"\"",
")",
"]",
")",
";",
"return",
"false",
";",
"}",
"else",
"{",
"prop",
"=",
"hashObject",
"[",
"key",
"]",
";",
"if",
"(",
"this",
".",
"_typeUtil",
".",
"isString",
"(",
"prop",
")",
")",
"{",
"if",
"(",
"re",
"&&",
"prop",
".",
"match",
"(",
"re",
")",
")",
"{",
"this",
".",
"$logError",
"(",
"this",
".",
"INVALID_HASHOBJECT_VALUE",
",",
"[",
"prop",
",",
"key",
",",
"this",
".",
"_nonEncodableSeparators",
".",
"join",
"(",
"\"\"",
")",
"]",
")",
";",
"return",
"false",
";",
"}",
"}",
"else",
"{",
"this",
".",
"$logError",
"(",
"this",
".",
"INVALID_HASHOBJECT_TYPE",
",",
"key",
")",
";",
"return",
"false",
";",
"}",
"}",
"}",
"}",
"return",
"true",
";",
"}"
] |
Checks that the values contained in the hashObject are strings and that both the keys and the values do not
contain any of the characters specified as separators that cannot be encoded
@param {Object} hashObject
@return {Boolean} true if the hashObject is valid, false otherwise
@protected
|
[
"Checks",
"that",
"the",
"values",
"contained",
"in",
"the",
"hashObject",
"are",
"strings",
"and",
"that",
"both",
"the",
"keys",
"and",
"the",
"values",
"do",
"not",
"contain",
"any",
"of",
"the",
"characters",
"specified",
"as",
"separators",
"that",
"cannot",
"be",
"encoded"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/HashManager.js#L465-L488
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/utils/HashManager.js
|
function (sep) {
var nonEncodedSep = [];
for (var i = 0, len = sep.length; i < len; i++) {
if (sep[i] == encodeURIComponent(sep[i])) {
nonEncodedSep.push(sep[i]);
}
}
return nonEncodedSep;
}
|
javascript
|
function (sep) {
var nonEncodedSep = [];
for (var i = 0, len = sep.length; i < len; i++) {
if (sep[i] == encodeURIComponent(sep[i])) {
nonEncodedSep.push(sep[i]);
}
}
return nonEncodedSep;
}
|
[
"function",
"(",
"sep",
")",
"{",
"var",
"nonEncodedSep",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"sep",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"sep",
"[",
"i",
"]",
"==",
"encodeURIComponent",
"(",
"sep",
"[",
"i",
"]",
")",
")",
"{",
"nonEncodedSep",
".",
"push",
"(",
"sep",
"[",
"i",
"]",
")",
";",
"}",
"}",
"return",
"nonEncodedSep",
";",
"}"
] |
Return the array of separators that cannot be encoded
@param {Array} sep Array of separators
@return {Array} array of non encodable separators
|
[
"Return",
"the",
"array",
"of",
"separators",
"that",
"cannot",
"be",
"encoded"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/HashManager.js#L495-L503
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/utils/HashManager.js
|
function (arg) {
var specialCharRegExp = /([\^\$\.\*\+\?\=\!\:\|\\\/\(\)\[\]\{\}]){1,1}/g;
var regexpStringArray = [];
for (var i = 0, len = arg.length; i < len; i++) {
regexpStringArray.push(arg[i].replace(specialCharRegExp, "\\$1"));
}
if (regexpStringArray.length === 0) {
return null;
} else {
return new RegExp(regexpStringArray.join("|"));
}
}
|
javascript
|
function (arg) {
var specialCharRegExp = /([\^\$\.\*\+\?\=\!\:\|\\\/\(\)\[\]\{\}]){1,1}/g;
var regexpStringArray = [];
for (var i = 0, len = arg.length; i < len; i++) {
regexpStringArray.push(arg[i].replace(specialCharRegExp, "\\$1"));
}
if (regexpStringArray.length === 0) {
return null;
} else {
return new RegExp(regexpStringArray.join("|"));
}
}
|
[
"function",
"(",
"arg",
")",
"{",
"var",
"specialCharRegExp",
"=",
"/",
"([\\^\\$\\.\\*\\+\\?\\=\\!\\:\\|\\\\\\/\\(\\)\\[\\]\\{\\}]){1,1}",
"/",
"g",
";",
"var",
"regexpStringArray",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"arg",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"regexpStringArray",
".",
"push",
"(",
"arg",
"[",
"i",
"]",
".",
"replace",
"(",
"specialCharRegExp",
",",
"\"\\\\$1\"",
")",
")",
";",
"}",
"\\\\",
"}"
] |
Return the regular expression needed to match one occurrence of any of the strings specified in the entries
of the array
@param {Array} arg Array of alternatives
@return {RegExp}
|
[
"Return",
"the",
"regular",
"expression",
"needed",
"to",
"match",
"one",
"occurrence",
"of",
"any",
"of",
"the",
"strings",
"specified",
"in",
"the",
"entries",
"of",
"the",
"array"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/HashManager.js#L511-L522
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/utils/HashManager.js
|
function () {
var iframe, document = Aria.$window.document;
iframe = document.createElement('iframe');
iframe.setAttribute('id', this.IFRAME_ID);
iframe.style.display = 'none';
document.body.appendChild(iframe);
this._iframe = iframe;
this.polledIframeHashString = this._currentHashString;
this._addIframeHistoryEntry(this._currentHashString);
}
|
javascript
|
function () {
var iframe, document = Aria.$window.document;
iframe = document.createElement('iframe');
iframe.setAttribute('id', this.IFRAME_ID);
iframe.style.display = 'none';
document.body.appendChild(iframe);
this._iframe = iframe;
this.polledIframeHashString = this._currentHashString;
this._addIframeHistoryEntry(this._currentHashString);
}
|
[
"function",
"(",
")",
"{",
"var",
"iframe",
",",
"document",
"=",
"Aria",
".",
"$window",
".",
"document",
";",
"iframe",
"=",
"document",
".",
"createElement",
"(",
"'iframe'",
")",
";",
"iframe",
".",
"setAttribute",
"(",
"'id'",
",",
"this",
".",
"IFRAME_ID",
")",
";",
"iframe",
".",
"style",
".",
"display",
"=",
"'none'",
";",
"document",
".",
"body",
".",
"appendChild",
"(",
"iframe",
")",
";",
"this",
".",
"_iframe",
"=",
"iframe",
";",
"this",
".",
"polledIframeHashString",
"=",
"this",
".",
"_currentHashString",
";",
"this",
".",
"_addIframeHistoryEntry",
"(",
"this",
".",
"_currentHashString",
")",
";",
"}"
] |
Create an iframe that is used to simulate a history in browsers that do not do that in the main window on
hash change
@protected
|
[
"Create",
"an",
"iframe",
"that",
"is",
"used",
"to",
"simulate",
"a",
"history",
"in",
"browsers",
"that",
"do",
"not",
"do",
"that",
"in",
"the",
"main",
"window",
"on",
"hash",
"change"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/HashManager.js#L529-L544
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/utils/HashManager.js
|
function (hash) {
var iframe = this._iframe;
if (!iframe) {
return;
}
hash = hash || "";
if (this._currentIframeHashString != hash) {
var src = ['javascript:document.open();'];
src.push('document.write(\"<script type=\\\"text/javascript\\\">');
if (Aria.domain) {
src.push('document.domain=\\\"' + Aria.domain + '\\\";');
}
src.push('if (parent.' + this.$classpath + '){parent.' + this.$classpath
+ '.polledIframeHashString=\\\"' + hash + '\\\";}');
src.push("</script>\");");
src.push('document.close();');
iframe.src = src.join("");
this._currentIframeHashString = hash;
}
}
|
javascript
|
function (hash) {
var iframe = this._iframe;
if (!iframe) {
return;
}
hash = hash || "";
if (this._currentIframeHashString != hash) {
var src = ['javascript:document.open();'];
src.push('document.write(\"<script type=\\\"text/javascript\\\">');
if (Aria.domain) {
src.push('document.domain=\\\"' + Aria.domain + '\\\";');
}
src.push('if (parent.' + this.$classpath + '){parent.' + this.$classpath
+ '.polledIframeHashString=\\\"' + hash + '\\\";}');
src.push("</script>\");");
src.push('document.close();');
iframe.src = src.join("");
this._currentIframeHashString = hash;
}
}
|
[
"function",
"(",
"hash",
")",
"{",
"var",
"iframe",
"=",
"this",
".",
"_iframe",
";",
"if",
"(",
"!",
"iframe",
")",
"{",
"return",
";",
"}",
"hash",
"=",
"hash",
"||",
"\"\"",
";",
"if",
"(",
"this",
".",
"_currentIframeHashString",
"!=",
"hash",
")",
"{",
"var",
"src",
"=",
"[",
"'javascript:document.open();'",
"]",
";",
"src",
".",
"push",
"(",
"'document.write(\\\"<script type=\\\\\\\"text/javascript\\\\\\\">'",
")",
";",
"\\\"",
"\\\\",
"\\\"",
"\\\\",
"\\\"",
"if",
"(",
"Aria",
".",
"domain",
")",
"{",
"src",
".",
"push",
"(",
"'document.domain=\\\\\\\"'",
"+",
"\\\\",
"+",
"\\\"",
")",
";",
"}",
"}",
"}"
] |
Add a hash in the iframe history
@param {String} hash
@protected
|
[
"Add",
"a",
"hash",
"in",
"the",
"iframe",
"history"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/HashManager.js#L551-L570
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/container/Tooltip.js
|
function (widget, domEvt) {
if (!this._cfgOk) {
return;
}
if (this._popup && this._associatedWidget == widget) {
this._popup.cancelMouseOutTimer();
}
if (!this._showTimeout) {
this._showTimeout = timer.addCallback({
scope : this,
fn : this.showTooltip,
args : {
widget : widget,
absolutePosition : {
left : domEvt.clientX,
top : domEvt.clientY
}
},
delay : this._cfg.showDelay
});
}
}
|
javascript
|
function (widget, domEvt) {
if (!this._cfgOk) {
return;
}
if (this._popup && this._associatedWidget == widget) {
this._popup.cancelMouseOutTimer();
}
if (!this._showTimeout) {
this._showTimeout = timer.addCallback({
scope : this,
fn : this.showTooltip,
args : {
widget : widget,
absolutePosition : {
left : domEvt.clientX,
top : domEvt.clientY
}
},
delay : this._cfg.showDelay
});
}
}
|
[
"function",
"(",
"widget",
",",
"domEvt",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_cfgOk",
")",
"{",
"return",
";",
"}",
"if",
"(",
"this",
".",
"_popup",
"&&",
"this",
".",
"_associatedWidget",
"==",
"widget",
")",
"{",
"this",
".",
"_popup",
".",
"cancelMouseOutTimer",
"(",
")",
";",
"}",
"if",
"(",
"!",
"this",
".",
"_showTimeout",
")",
"{",
"this",
".",
"_showTimeout",
"=",
"timer",
".",
"addCallback",
"(",
"{",
"scope",
":",
"this",
",",
"fn",
":",
"this",
".",
"showTooltip",
",",
"args",
":",
"{",
"widget",
":",
"widget",
",",
"absolutePosition",
":",
"{",
"left",
":",
"domEvt",
".",
"clientX",
",",
"top",
":",
"domEvt",
".",
"clientY",
"}",
"}",
",",
"delay",
":",
"this",
".",
"_cfg",
".",
"showDelay",
"}",
")",
";",
"}",
"}"
] |
Called when the associated widget receives a mouseover event.
@param {aria.widgets.Widget} widget associated widget
@param {aria.DomEvent} domEvt
|
[
"Called",
"when",
"the",
"associated",
"widget",
"receives",
"a",
"mouseover",
"event",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/container/Tooltip.js#L137-L158
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/container/Tooltip.js
|
function (widget, domEvt) {
if (!this._cfgOk) {
return;
}
if (this._showTimeout && this._cfg.showOnlyOnMouseStill) {
timer.cancelCallback(this._showTimeout);
this._showTimeout = timer.addCallback({
scope : this,
fn : this.showTooltip,
args : {
widget : widget,
absolutePosition : {
left : domEvt.clientX,
top : domEvt.clientY
}
},
delay : this._cfg.showDelay
});
}
}
|
javascript
|
function (widget, domEvt) {
if (!this._cfgOk) {
return;
}
if (this._showTimeout && this._cfg.showOnlyOnMouseStill) {
timer.cancelCallback(this._showTimeout);
this._showTimeout = timer.addCallback({
scope : this,
fn : this.showTooltip,
args : {
widget : widget,
absolutePosition : {
left : domEvt.clientX,
top : domEvt.clientY
}
},
delay : this._cfg.showDelay
});
}
}
|
[
"function",
"(",
"widget",
",",
"domEvt",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_cfgOk",
")",
"{",
"return",
";",
"}",
"if",
"(",
"this",
".",
"_showTimeout",
"&&",
"this",
".",
"_cfg",
".",
"showOnlyOnMouseStill",
")",
"{",
"timer",
".",
"cancelCallback",
"(",
"this",
".",
"_showTimeout",
")",
";",
"this",
".",
"_showTimeout",
"=",
"timer",
".",
"addCallback",
"(",
"{",
"scope",
":",
"this",
",",
"fn",
":",
"this",
".",
"showTooltip",
",",
"args",
":",
"{",
"widget",
":",
"widget",
",",
"absolutePosition",
":",
"{",
"left",
":",
"domEvt",
".",
"clientX",
",",
"top",
":",
"domEvt",
".",
"clientY",
"}",
"}",
",",
"delay",
":",
"this",
".",
"_cfg",
".",
"showDelay",
"}",
")",
";",
"}",
"}"
] |
Called when the associated widget receives a mousemove event.
@param {aria.widgets.widget} widget associated widget
@param {aria.DomEvent} domEvt
|
[
"Called",
"when",
"the",
"associated",
"widget",
"receives",
"a",
"mousemove",
"event",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/container/Tooltip.js#L164-L183
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/container/Tooltip.js
|
function (widget, domEvt) {
if (!this._cfgOk) {
return;
}
if (this._popup) {
this._popup.closeOnMouseOut(domEvt);
}
if (this._showTimeout) {
timer.cancelCallback(this._showTimeout);
this._showTimeout = null;
}
}
|
javascript
|
function (widget, domEvt) {
if (!this._cfgOk) {
return;
}
if (this._popup) {
this._popup.closeOnMouseOut(domEvt);
}
if (this._showTimeout) {
timer.cancelCallback(this._showTimeout);
this._showTimeout = null;
}
}
|
[
"function",
"(",
"widget",
",",
"domEvt",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_cfgOk",
")",
"{",
"return",
";",
"}",
"if",
"(",
"this",
".",
"_popup",
")",
"{",
"this",
".",
"_popup",
".",
"closeOnMouseOut",
"(",
"domEvt",
")",
";",
"}",
"if",
"(",
"this",
".",
"_showTimeout",
")",
"{",
"timer",
".",
"cancelCallback",
"(",
"this",
".",
"_showTimeout",
")",
";",
"this",
".",
"_showTimeout",
"=",
"null",
";",
"}",
"}"
] |
Called when the associated widget receives a mouseout event.
@param {aria.widgets.Widget} widget associated widget
@param {aria.DomEvent} domEvt
|
[
"Called",
"when",
"the",
"associated",
"widget",
"receives",
"a",
"mouseout",
"event",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/container/Tooltip.js#L189-L200
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/form/list/ListController.js
|
function (args, cb) {
this.setData(args.dataModel);
var itemsInfo = args.itemsInfo;
var res = this._mergeItemsAndSelectionInfo(itemsInfo.items, itemsInfo.selectedValues, itemsInfo.selectedIndex);
this._setItems(res.items);
this.json.setValue(this._data, "selectedIndex", res.selectedIndex);
this.json.setValue(this._data, "selectedCount", res.selectedCount);
// this.json.setValue(this._data, "selectedValues", res.selectedValues);
if (itemsInfo.selectedValues == null) {
this.setSelectedIndex(itemsInfo.selectedIndex);
}
var itemsView = new ariaTemplatesView(this._data.items);
this.json.setValue(this._data, "itemsView", itemsView);
if (this._data.activateSort) {
itemsView.setSort(itemsView.SORT_ASCENDING, "sortByLabel", this._sortByLabel);
}
this.$callback(cb);
}
|
javascript
|
function (args, cb) {
this.setData(args.dataModel);
var itemsInfo = args.itemsInfo;
var res = this._mergeItemsAndSelectionInfo(itemsInfo.items, itemsInfo.selectedValues, itemsInfo.selectedIndex);
this._setItems(res.items);
this.json.setValue(this._data, "selectedIndex", res.selectedIndex);
this.json.setValue(this._data, "selectedCount", res.selectedCount);
// this.json.setValue(this._data, "selectedValues", res.selectedValues);
if (itemsInfo.selectedValues == null) {
this.setSelectedIndex(itemsInfo.selectedIndex);
}
var itemsView = new ariaTemplatesView(this._data.items);
this.json.setValue(this._data, "itemsView", itemsView);
if (this._data.activateSort) {
itemsView.setSort(itemsView.SORT_ASCENDING, "sortByLabel", this._sortByLabel);
}
this.$callback(cb);
}
|
[
"function",
"(",
"args",
",",
"cb",
")",
"{",
"this",
".",
"setData",
"(",
"args",
".",
"dataModel",
")",
";",
"var",
"itemsInfo",
"=",
"args",
".",
"itemsInfo",
";",
"var",
"res",
"=",
"this",
".",
"_mergeItemsAndSelectionInfo",
"(",
"itemsInfo",
".",
"items",
",",
"itemsInfo",
".",
"selectedValues",
",",
"itemsInfo",
".",
"selectedIndex",
")",
";",
"this",
".",
"_setItems",
"(",
"res",
".",
"items",
")",
";",
"this",
".",
"json",
".",
"setValue",
"(",
"this",
".",
"_data",
",",
"\"selectedIndex\"",
",",
"res",
".",
"selectedIndex",
")",
";",
"this",
".",
"json",
".",
"setValue",
"(",
"this",
".",
"_data",
",",
"\"selectedCount\"",
",",
"res",
".",
"selectedCount",
")",
";",
"if",
"(",
"itemsInfo",
".",
"selectedValues",
"==",
"null",
")",
"{",
"this",
".",
"setSelectedIndex",
"(",
"itemsInfo",
".",
"selectedIndex",
")",
";",
"}",
"var",
"itemsView",
"=",
"new",
"ariaTemplatesView",
"(",
"this",
".",
"_data",
".",
"items",
")",
";",
"this",
".",
"json",
".",
"setValue",
"(",
"this",
".",
"_data",
",",
"\"itemsView\"",
",",
"itemsView",
")",
";",
"if",
"(",
"this",
".",
"_data",
".",
"activateSort",
")",
"{",
"itemsView",
".",
"setSort",
"(",
"itemsView",
".",
"SORT_ASCENDING",
",",
"\"sortByLabel\"",
",",
"this",
".",
"_sortByLabel",
")",
";",
"}",
"this",
".",
"$callback",
"(",
"cb",
")",
";",
"}"
] |
Initialise the module controller
@param {Object} args
@param {aria.core.CfgBeans:Callback} cb callback
|
[
"Initialise",
"the",
"module",
"controller"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/list/ListController.js#L77-L101
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/form/list/ListController.js
|
function (selectedIdx) {
if (!this._navigationEvent) { // will not override any selections using arrow keys or mouse over
if (this._data.preselect === "none") {
return null;
} else if (this._data.preselect === "always") {
if (selectedIdx === -1 || selectedIdx === undefined) {
selectedIdx = 0;
}
return selectedIdx;
}
} else {
this._navigationEvent = false;
}
}
|
javascript
|
function (selectedIdx) {
if (!this._navigationEvent) { // will not override any selections using arrow keys or mouse over
if (this._data.preselect === "none") {
return null;
} else if (this._data.preselect === "always") {
if (selectedIdx === -1 || selectedIdx === undefined) {
selectedIdx = 0;
}
return selectedIdx;
}
} else {
this._navigationEvent = false;
}
}
|
[
"function",
"(",
"selectedIdx",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_navigationEvent",
")",
"{",
"if",
"(",
"this",
".",
"_data",
".",
"preselect",
"===",
"\"none\"",
")",
"{",
"return",
"null",
";",
"}",
"else",
"if",
"(",
"this",
".",
"_data",
".",
"preselect",
"===",
"\"always\"",
")",
"{",
"if",
"(",
"selectedIdx",
"===",
"-",
"1",
"||",
"selectedIdx",
"===",
"undefined",
")",
"{",
"selectedIdx",
"=",
"0",
";",
"}",
"return",
"selectedIdx",
";",
"}",
"}",
"else",
"{",
"this",
".",
"_navigationEvent",
"=",
"false",
";",
"}",
"}"
] |
Return the item that should be preselected depending on the navigation event
@param {Integer} selectedIdx selected option index
@protected
@return {Integer} Item position or null if nothing should be preselected
|
[
"Return",
"the",
"item",
"that",
"should",
"be",
"preselected",
"depending",
"on",
"the",
"navigation",
"event"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/list/ListController.js#L120-L133
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/form/list/ListController.js
|
function (itemsList) {
var selectedCount = this._data.selectedCount;
var maxSelectedCount = this._getTrueMaxSelectedCount();
for (var i = 0, l = itemsList.length; i < l; i++) {
var item = itemsList[i];
var res = item.initiallyDisabled;
if (!res && selectedCount >= maxSelectedCount) {
res = !item.selected;
}
this.json.setValue(item, "currentlyDisabled", res);
}
}
|
javascript
|
function (itemsList) {
var selectedCount = this._data.selectedCount;
var maxSelectedCount = this._getTrueMaxSelectedCount();
for (var i = 0, l = itemsList.length; i < l; i++) {
var item = itemsList[i];
var res = item.initiallyDisabled;
if (!res && selectedCount >= maxSelectedCount) {
res = !item.selected;
}
this.json.setValue(item, "currentlyDisabled", res);
}
}
|
[
"function",
"(",
"itemsList",
")",
"{",
"var",
"selectedCount",
"=",
"this",
".",
"_data",
".",
"selectedCount",
";",
"var",
"maxSelectedCount",
"=",
"this",
".",
"_getTrueMaxSelectedCount",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"itemsList",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"var",
"item",
"=",
"itemsList",
"[",
"i",
"]",
";",
"var",
"res",
"=",
"item",
".",
"initiallyDisabled",
";",
"if",
"(",
"!",
"res",
"&&",
"selectedCount",
">=",
"maxSelectedCount",
")",
"{",
"res",
"=",
"!",
"item",
".",
"selected",
";",
"}",
"this",
".",
"json",
".",
"setValue",
"(",
"item",
",",
"\"currentlyDisabled\"",
",",
"res",
")",
";",
"}",
"}"
] |
Update the currentlyDisabled properties of each item in itemsList, based on the initiallyDisabled and
selected properties and on the current number of selected items.
@param {Array} itemsList array of items (sub-array of this._data.items) whose currentlyDisabled properties
have to be updated
@protected
|
[
"Update",
"the",
"currentlyDisabled",
"properties",
"of",
"each",
"item",
"in",
"itemsList",
"based",
"on",
"the",
"initiallyDisabled",
"and",
"selected",
"properties",
"and",
"on",
"the",
"current",
"number",
"of",
"selected",
"items",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/list/ListController.js#L202-L213
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/form/list/ListController.js
|
function (itemIndex) {
this._stopUpdates();
var json = this.json;
var data = this._data;
var itemsList = data.items;
var item = itemsList[itemIndex];
var isSelected = item.selected;
// Needed to optimize the template
var newlySelectedIndexes = [];
var newlyUnselectedIndexes = [];
// items for which _updateCurrentlyDisabled will be called:
var changedItems = [item];
var maxSelectedCount = this._getTrueMaxSelectedCount();
var previousSelectedCount = data.selectedCount;
var newSelectedIndex = data.selectedIndex;
var newSelectedCount = previousSelectedCount;
this.$assert(149, maxSelectedCount >= previousSelectedCount);
// now we need to update the selectedIndex and selectedCount properties
// and also the selection of other items (if max selected count has been reached)
if (isSelected) {
newlySelectedIndexes[0] = itemIndex;
newSelectedCount++;
if (newSelectedCount > maxSelectedCount) {
// selecting a new item would be a problem, we need to unselect another item for this to work
var selectedIndexes = this.getSelectedIndexes(); // this may or may not contain itemIndex
// (depending on selectedIndex)
for (var i = 0, len = selectedIndexes.length; i < len; i++) {
var indexSelected = selectedIndexes[i];
if (indexSelected != itemIndex) { // do not unselect the item that has just been selected
var itemToUnselect = itemsList[indexSelected];
// check initiallyDisabled so that programmatically disabled items cannot be unselected
// here
if (!itemToUnselect.initiallyDisabled) {
// we found an item to unselect
newSelectedCount--;
newlyUnselectedIndexes[0] = indexSelected;
json.setValue(itemToUnselect, "selected", false);
changedItems.push(itemToUnselect);
break;
}
}
}
this.$assert(182, newSelectedCount == maxSelectedCount); // we must have found an item to
// unselect
}
if (newSelectedCount === 1) {
newSelectedIndex = itemIndex;
} else {
// more than 1 selected item
newSelectedIndex = null;
}
} else {
newlyUnselectedIndexes[0] = itemIndex;
newSelectedCount--;
if (newSelectedCount === 0) {
this.$assert(194, newSelectedIndex == itemIndex); // it was the only selected item
newSelectedIndex = -1;
} else if (newSelectedCount === 1) {
// one remaining selected item, need to find which one
var selectedIndexes = this.getSelectedIndexes();
this.$assert(202, selectedIndexes.length == 1);
newSelectedIndex = selectedIndexes[0];
} else {
// more than one remaining selected item, nothing to do with newSelectedIndex
this.$assert(203, newSelectedCount > 1);
this.$assert(204, newSelectedIndex == null);
}
}
json.setValue(data, "selectedIndex", newSelectedIndex);
json.setValue(data, "selectedCount", newSelectedCount);
if ((newSelectedCount != previousSelectedCount)
&& (previousSelectedCount == maxSelectedCount || newSelectedCount == maxSelectedCount)) {
// the number of selected items has changed, and it either the old or the new number is the maximum
// number
// update all disabled information
this._updateCurrentlyDisabled(itemsList);
} else {
this._updateCurrentlyDisabled(changedItems);
}
this._resumeUpdates();
// after everything is updated, send the event:
this._raiseOnChangeEvent(newlySelectedIndexes, newlyUnselectedIndexes);
}
|
javascript
|
function (itemIndex) {
this._stopUpdates();
var json = this.json;
var data = this._data;
var itemsList = data.items;
var item = itemsList[itemIndex];
var isSelected = item.selected;
// Needed to optimize the template
var newlySelectedIndexes = [];
var newlyUnselectedIndexes = [];
// items for which _updateCurrentlyDisabled will be called:
var changedItems = [item];
var maxSelectedCount = this._getTrueMaxSelectedCount();
var previousSelectedCount = data.selectedCount;
var newSelectedIndex = data.selectedIndex;
var newSelectedCount = previousSelectedCount;
this.$assert(149, maxSelectedCount >= previousSelectedCount);
// now we need to update the selectedIndex and selectedCount properties
// and also the selection of other items (if max selected count has been reached)
if (isSelected) {
newlySelectedIndexes[0] = itemIndex;
newSelectedCount++;
if (newSelectedCount > maxSelectedCount) {
// selecting a new item would be a problem, we need to unselect another item for this to work
var selectedIndexes = this.getSelectedIndexes(); // this may or may not contain itemIndex
// (depending on selectedIndex)
for (var i = 0, len = selectedIndexes.length; i < len; i++) {
var indexSelected = selectedIndexes[i];
if (indexSelected != itemIndex) { // do not unselect the item that has just been selected
var itemToUnselect = itemsList[indexSelected];
// check initiallyDisabled so that programmatically disabled items cannot be unselected
// here
if (!itemToUnselect.initiallyDisabled) {
// we found an item to unselect
newSelectedCount--;
newlyUnselectedIndexes[0] = indexSelected;
json.setValue(itemToUnselect, "selected", false);
changedItems.push(itemToUnselect);
break;
}
}
}
this.$assert(182, newSelectedCount == maxSelectedCount); // we must have found an item to
// unselect
}
if (newSelectedCount === 1) {
newSelectedIndex = itemIndex;
} else {
// more than 1 selected item
newSelectedIndex = null;
}
} else {
newlyUnselectedIndexes[0] = itemIndex;
newSelectedCount--;
if (newSelectedCount === 0) {
this.$assert(194, newSelectedIndex == itemIndex); // it was the only selected item
newSelectedIndex = -1;
} else if (newSelectedCount === 1) {
// one remaining selected item, need to find which one
var selectedIndexes = this.getSelectedIndexes();
this.$assert(202, selectedIndexes.length == 1);
newSelectedIndex = selectedIndexes[0];
} else {
// more than one remaining selected item, nothing to do with newSelectedIndex
this.$assert(203, newSelectedCount > 1);
this.$assert(204, newSelectedIndex == null);
}
}
json.setValue(data, "selectedIndex", newSelectedIndex);
json.setValue(data, "selectedCount", newSelectedCount);
if ((newSelectedCount != previousSelectedCount)
&& (previousSelectedCount == maxSelectedCount || newSelectedCount == maxSelectedCount)) {
// the number of selected items has changed, and it either the old or the new number is the maximum
// number
// update all disabled information
this._updateCurrentlyDisabled(itemsList);
} else {
this._updateCurrentlyDisabled(changedItems);
}
this._resumeUpdates();
// after everything is updated, send the event:
this._raiseOnChangeEvent(newlySelectedIndexes, newlyUnselectedIndexes);
}
|
[
"function",
"(",
"itemIndex",
")",
"{",
"this",
".",
"_stopUpdates",
"(",
")",
";",
"var",
"json",
"=",
"this",
".",
"json",
";",
"var",
"data",
"=",
"this",
".",
"_data",
";",
"var",
"itemsList",
"=",
"data",
".",
"items",
";",
"var",
"item",
"=",
"itemsList",
"[",
"itemIndex",
"]",
";",
"var",
"isSelected",
"=",
"item",
".",
"selected",
";",
"var",
"newlySelectedIndexes",
"=",
"[",
"]",
";",
"var",
"newlyUnselectedIndexes",
"=",
"[",
"]",
";",
"var",
"changedItems",
"=",
"[",
"item",
"]",
";",
"var",
"maxSelectedCount",
"=",
"this",
".",
"_getTrueMaxSelectedCount",
"(",
")",
";",
"var",
"previousSelectedCount",
"=",
"data",
".",
"selectedCount",
";",
"var",
"newSelectedIndex",
"=",
"data",
".",
"selectedIndex",
";",
"var",
"newSelectedCount",
"=",
"previousSelectedCount",
";",
"this",
".",
"$assert",
"(",
"149",
",",
"maxSelectedCount",
">=",
"previousSelectedCount",
")",
";",
"if",
"(",
"isSelected",
")",
"{",
"newlySelectedIndexes",
"[",
"0",
"]",
"=",
"itemIndex",
";",
"newSelectedCount",
"++",
";",
"if",
"(",
"newSelectedCount",
">",
"maxSelectedCount",
")",
"{",
"var",
"selectedIndexes",
"=",
"this",
".",
"getSelectedIndexes",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"selectedIndexes",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"var",
"indexSelected",
"=",
"selectedIndexes",
"[",
"i",
"]",
";",
"if",
"(",
"indexSelected",
"!=",
"itemIndex",
")",
"{",
"var",
"itemToUnselect",
"=",
"itemsList",
"[",
"indexSelected",
"]",
";",
"if",
"(",
"!",
"itemToUnselect",
".",
"initiallyDisabled",
")",
"{",
"newSelectedCount",
"--",
";",
"newlyUnselectedIndexes",
"[",
"0",
"]",
"=",
"indexSelected",
";",
"json",
".",
"setValue",
"(",
"itemToUnselect",
",",
"\"selected\"",
",",
"false",
")",
";",
"changedItems",
".",
"push",
"(",
"itemToUnselect",
")",
";",
"break",
";",
"}",
"}",
"}",
"this",
".",
"$assert",
"(",
"182",
",",
"newSelectedCount",
"==",
"maxSelectedCount",
")",
";",
"}",
"if",
"(",
"newSelectedCount",
"===",
"1",
")",
"{",
"newSelectedIndex",
"=",
"itemIndex",
";",
"}",
"else",
"{",
"newSelectedIndex",
"=",
"null",
";",
"}",
"}",
"else",
"{",
"newlyUnselectedIndexes",
"[",
"0",
"]",
"=",
"itemIndex",
";",
"newSelectedCount",
"--",
";",
"if",
"(",
"newSelectedCount",
"===",
"0",
")",
"{",
"this",
".",
"$assert",
"(",
"194",
",",
"newSelectedIndex",
"==",
"itemIndex",
")",
";",
"newSelectedIndex",
"=",
"-",
"1",
";",
"}",
"else",
"if",
"(",
"newSelectedCount",
"===",
"1",
")",
"{",
"var",
"selectedIndexes",
"=",
"this",
".",
"getSelectedIndexes",
"(",
")",
";",
"this",
".",
"$assert",
"(",
"202",
",",
"selectedIndexes",
".",
"length",
"==",
"1",
")",
";",
"newSelectedIndex",
"=",
"selectedIndexes",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"this",
".",
"$assert",
"(",
"203",
",",
"newSelectedCount",
">",
"1",
")",
";",
"this",
".",
"$assert",
"(",
"204",
",",
"newSelectedIndex",
"==",
"null",
")",
";",
"}",
"}",
"json",
".",
"setValue",
"(",
"data",
",",
"\"selectedIndex\"",
",",
"newSelectedIndex",
")",
";",
"json",
".",
"setValue",
"(",
"data",
",",
"\"selectedCount\"",
",",
"newSelectedCount",
")",
";",
"if",
"(",
"(",
"newSelectedCount",
"!=",
"previousSelectedCount",
")",
"&&",
"(",
"previousSelectedCount",
"==",
"maxSelectedCount",
"||",
"newSelectedCount",
"==",
"maxSelectedCount",
")",
")",
"{",
"this",
".",
"_updateCurrentlyDisabled",
"(",
"itemsList",
")",
";",
"}",
"else",
"{",
"this",
".",
"_updateCurrentlyDisabled",
"(",
"changedItems",
")",
";",
"}",
"this",
".",
"_resumeUpdates",
"(",
")",
";",
"this",
".",
"_raiseOnChangeEvent",
"(",
"newlySelectedIndexes",
",",
"newlyUnselectedIndexes",
")",
";",
"}"
] |
Called when the selected property of an item changed. This method updates the selectedCount and selectedIndex
properties in the data model and unselect other items if the maximum number of selected items has been
reached.
@param {Number} itemIndex item whose selected property has just changed.
@protected
|
[
"Called",
"when",
"the",
"selected",
"property",
"of",
"an",
"item",
"changed",
".",
"This",
"method",
"updates",
"the",
"selectedCount",
"and",
"selectedIndex",
"properties",
"in",
"the",
"data",
"model",
"and",
"unselect",
"other",
"items",
"if",
"the",
"maximum",
"number",
"of",
"selected",
"items",
"has",
"been",
"reached",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/list/ListController.js#L222-L309
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/form/list/ListController.js
|
function (items, selectedValues, selectedIdx) {
var arrayUtil = ariaUtilsArray;
var preselect = this._checkPreselect(selectedIdx);
selectedIdx = (preselect === undefined) ? selectedIdx : preselect;
var maxSelectedCount = this._getTrueMaxSelectedCount(items);
var pbMaxSelected = false; // true if the number of selected values is greater than maxSelectedCount
// Items can be taken directly from the array or from another array
// Identify from which container we'll take the items and from which properties.
var container = items;
var labelProperty = "label";
var ariaLabelProperty = "ariaLabel";
var valueProperty = "value";
var disabledProperty = "disabled";
if (!ariaUtilsType.isArray(items)) {
container = items.container;
labelProperty = items.labelProperty;
ariaLabelProperty = items.ariaLabelProperty;
valueProperty = items.valueProperty;
disabledProperty = items.disabledProperty;
}
// Merge the item data and info about selection in one array for simpler template construction
var listItems = [];
var selectedIndex = -1;
var selectedCount = 0;
for (var item = 0, length = container.length; item < length; item++) {
var itemObj = container[item];
var itemSelected = selectedValues ? arrayUtil.contains(selectedValues, itemObj[valueProperty])
|| selectedIdx === item : false;
if (items[item].disabled) {
itemSelected = false;
}
if (itemSelected) {
if (selectedCount < maxSelectedCount) {
selectedCount++;
if (selectedIndex != null) {
if (selectedIndex == -1) {
selectedIndex = item; // only one item is selected
} else {
selectedIndex = null; // multiple items are selected
}
}
} else {
pbMaxSelected = true;
// we do as if this item was not selected, as we have reached the
// maximum number of selected items
itemSelected = false;
}
}
var initiallyDisabled = disabledProperty ? itemObj[disabledProperty] : false;
listItems[item] = {
index : item,
label : itemObj[labelProperty],
ariaLabel : itemObj[ariaLabelProperty],
value : itemObj[valueProperty],
object : itemObj,
selected : itemSelected,
initiallyDisabled : initiallyDisabled,
currentlyDisabled : initiallyDisabled
// currentlyDisabled will be updated at the end if the maximum number of selected items has been
// reached
};
}
// check if the maximum number of items has been reached:
if (selectedCount == maxSelectedCount) {
// in this case, all the unselected items must be disabled:
for (var item = 0, length = listItems.length; item < length; item++) {
if (!listItems[item].selected) {
listItems[item].currentlyDisabled = true;
}
}
}
// In case of single selection mode, we keep track of the current selected index
// to avoid looping through all elements when doing new selection.
return {
items : listItems,
pbMaxSelected : pbMaxSelected,
selectedIndex : selectedIndex,
selectedCount : selectedCount
};
}
|
javascript
|
function (items, selectedValues, selectedIdx) {
var arrayUtil = ariaUtilsArray;
var preselect = this._checkPreselect(selectedIdx);
selectedIdx = (preselect === undefined) ? selectedIdx : preselect;
var maxSelectedCount = this._getTrueMaxSelectedCount(items);
var pbMaxSelected = false; // true if the number of selected values is greater than maxSelectedCount
// Items can be taken directly from the array or from another array
// Identify from which container we'll take the items and from which properties.
var container = items;
var labelProperty = "label";
var ariaLabelProperty = "ariaLabel";
var valueProperty = "value";
var disabledProperty = "disabled";
if (!ariaUtilsType.isArray(items)) {
container = items.container;
labelProperty = items.labelProperty;
ariaLabelProperty = items.ariaLabelProperty;
valueProperty = items.valueProperty;
disabledProperty = items.disabledProperty;
}
// Merge the item data and info about selection in one array for simpler template construction
var listItems = [];
var selectedIndex = -1;
var selectedCount = 0;
for (var item = 0, length = container.length; item < length; item++) {
var itemObj = container[item];
var itemSelected = selectedValues ? arrayUtil.contains(selectedValues, itemObj[valueProperty])
|| selectedIdx === item : false;
if (items[item].disabled) {
itemSelected = false;
}
if (itemSelected) {
if (selectedCount < maxSelectedCount) {
selectedCount++;
if (selectedIndex != null) {
if (selectedIndex == -1) {
selectedIndex = item; // only one item is selected
} else {
selectedIndex = null; // multiple items are selected
}
}
} else {
pbMaxSelected = true;
// we do as if this item was not selected, as we have reached the
// maximum number of selected items
itemSelected = false;
}
}
var initiallyDisabled = disabledProperty ? itemObj[disabledProperty] : false;
listItems[item] = {
index : item,
label : itemObj[labelProperty],
ariaLabel : itemObj[ariaLabelProperty],
value : itemObj[valueProperty],
object : itemObj,
selected : itemSelected,
initiallyDisabled : initiallyDisabled,
currentlyDisabled : initiallyDisabled
// currentlyDisabled will be updated at the end if the maximum number of selected items has been
// reached
};
}
// check if the maximum number of items has been reached:
if (selectedCount == maxSelectedCount) {
// in this case, all the unselected items must be disabled:
for (var item = 0, length = listItems.length; item < length; item++) {
if (!listItems[item].selected) {
listItems[item].currentlyDisabled = true;
}
}
}
// In case of single selection mode, we keep track of the current selected index
// to avoid looping through all elements when doing new selection.
return {
items : listItems,
pbMaxSelected : pbMaxSelected,
selectedIndex : selectedIndex,
selectedCount : selectedCount
};
}
|
[
"function",
"(",
"items",
",",
"selectedValues",
",",
"selectedIdx",
")",
"{",
"var",
"arrayUtil",
"=",
"ariaUtilsArray",
";",
"var",
"preselect",
"=",
"this",
".",
"_checkPreselect",
"(",
"selectedIdx",
")",
";",
"selectedIdx",
"=",
"(",
"preselect",
"===",
"undefined",
")",
"?",
"selectedIdx",
":",
"preselect",
";",
"var",
"maxSelectedCount",
"=",
"this",
".",
"_getTrueMaxSelectedCount",
"(",
"items",
")",
";",
"var",
"pbMaxSelected",
"=",
"false",
";",
"var",
"container",
"=",
"items",
";",
"var",
"labelProperty",
"=",
"\"label\"",
";",
"var",
"ariaLabelProperty",
"=",
"\"ariaLabel\"",
";",
"var",
"valueProperty",
"=",
"\"value\"",
";",
"var",
"disabledProperty",
"=",
"\"disabled\"",
";",
"if",
"(",
"!",
"ariaUtilsType",
".",
"isArray",
"(",
"items",
")",
")",
"{",
"container",
"=",
"items",
".",
"container",
";",
"labelProperty",
"=",
"items",
".",
"labelProperty",
";",
"ariaLabelProperty",
"=",
"items",
".",
"ariaLabelProperty",
";",
"valueProperty",
"=",
"items",
".",
"valueProperty",
";",
"disabledProperty",
"=",
"items",
".",
"disabledProperty",
";",
"}",
"var",
"listItems",
"=",
"[",
"]",
";",
"var",
"selectedIndex",
"=",
"-",
"1",
";",
"var",
"selectedCount",
"=",
"0",
";",
"for",
"(",
"var",
"item",
"=",
"0",
",",
"length",
"=",
"container",
".",
"length",
";",
"item",
"<",
"length",
";",
"item",
"++",
")",
"{",
"var",
"itemObj",
"=",
"container",
"[",
"item",
"]",
";",
"var",
"itemSelected",
"=",
"selectedValues",
"?",
"arrayUtil",
".",
"contains",
"(",
"selectedValues",
",",
"itemObj",
"[",
"valueProperty",
"]",
")",
"||",
"selectedIdx",
"===",
"item",
":",
"false",
";",
"if",
"(",
"items",
"[",
"item",
"]",
".",
"disabled",
")",
"{",
"itemSelected",
"=",
"false",
";",
"}",
"if",
"(",
"itemSelected",
")",
"{",
"if",
"(",
"selectedCount",
"<",
"maxSelectedCount",
")",
"{",
"selectedCount",
"++",
";",
"if",
"(",
"selectedIndex",
"!=",
"null",
")",
"{",
"if",
"(",
"selectedIndex",
"==",
"-",
"1",
")",
"{",
"selectedIndex",
"=",
"item",
";",
"}",
"else",
"{",
"selectedIndex",
"=",
"null",
";",
"}",
"}",
"}",
"else",
"{",
"pbMaxSelected",
"=",
"true",
";",
"itemSelected",
"=",
"false",
";",
"}",
"}",
"var",
"initiallyDisabled",
"=",
"disabledProperty",
"?",
"itemObj",
"[",
"disabledProperty",
"]",
":",
"false",
";",
"listItems",
"[",
"item",
"]",
"=",
"{",
"index",
":",
"item",
",",
"label",
":",
"itemObj",
"[",
"labelProperty",
"]",
",",
"ariaLabel",
":",
"itemObj",
"[",
"ariaLabelProperty",
"]",
",",
"value",
":",
"itemObj",
"[",
"valueProperty",
"]",
",",
"object",
":",
"itemObj",
",",
"selected",
":",
"itemSelected",
",",
"initiallyDisabled",
":",
"initiallyDisabled",
",",
"currentlyDisabled",
":",
"initiallyDisabled",
"}",
";",
"}",
"if",
"(",
"selectedCount",
"==",
"maxSelectedCount",
")",
"{",
"for",
"(",
"var",
"item",
"=",
"0",
",",
"length",
"=",
"listItems",
".",
"length",
";",
"item",
"<",
"length",
";",
"item",
"++",
")",
"{",
"if",
"(",
"!",
"listItems",
"[",
"item",
"]",
".",
"selected",
")",
"{",
"listItems",
"[",
"item",
"]",
".",
"currentlyDisabled",
"=",
"true",
";",
"}",
"}",
"}",
"return",
"{",
"items",
":",
"listItems",
",",
"pbMaxSelected",
":",
"pbMaxSelected",
",",
"selectedIndex",
":",
"selectedIndex",
",",
"selectedCount",
":",
"selectedCount",
"}",
";",
"}"
] |
Merges item data in it's different formats with the selection info.
@param {} items The items in one of the accepted formats by the ListCfg bean. Can for example be an array
with label/value pairs, or a specification of a container and where to get the label and value properties in
that container.
@param {} selectedValues [optional] An array with values matching the value property in the items
@param Number selectedIdx [optional] Index of the item in selectedValues array which should be selected
parameter above.
@return {} Returns an object with 4 properties..
|
[
"Merges",
"item",
"data",
"in",
"it",
"s",
"different",
"formats",
"with",
"the",
"selection",
"info",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/list/ListController.js#L386-L468
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/form/list/ListController.js
|
function (flowOrientation, focusIndex, numberOfRows, numberOfColumns, keyCode, numberItems) {
var moveFocus = focusIndex;
if (numberOfColumns == 1) {
if (keyCode == ariaDomEvent.KC_ARROW_UP) {
moveFocus--;
}
if (keyCode == ariaDomEvent.KC_ARROW_DOWN) {
moveFocus++;
}
} else {
if (keyCode == ariaDomEvent.KC_ARROW_UP) {
if (flowOrientation == 'vertical') {
moveFocus = focusIndex - 1;
} else {
if (focusIndex - numberOfColumns < 0) {
moveFocus = focusIndex--;
} else {
moveFocus = focusIndex - numberOfColumns;
}
}
} else if (keyCode == ariaDomEvent.KC_ARROW_DOWN) {
if (flowOrientation == 'vertical') {
moveFocus = focusIndex + 1;
} else {
if (numberOfColumns < numberItems - focusIndex) {
moveFocus = focusIndex + numberOfColumns;
} else {
return focusIndex;
}
}
} else if (keyCode == ariaDomEvent.KC_ARROW_LEFT) {
if (flowOrientation == 'horizontal') {
moveFocus = focusIndex - 1;
} else {
if (focusIndex >= numberOfRows) {
moveFocus = focusIndex - numberOfRows;
} else {
return focusIndex;
}
}
} else if (keyCode == ariaDomEvent.KC_ARROW_RIGHT) {
if (flowOrientation == 'horizontal') {
moveFocus = focusIndex + 1;
} else {
if (numberOfColumns < numberItems - focusIndex) {
moveFocus = focusIndex + numberOfRows;
} else {
return focusIndex;
}
}
}
}
if (moveFocus >= numberItems) {
return numberItems - 1;
} else if (moveFocus < 0) {
return 0;
} else {
return moveFocus;
}
}
|
javascript
|
function (flowOrientation, focusIndex, numberOfRows, numberOfColumns, keyCode, numberItems) {
var moveFocus = focusIndex;
if (numberOfColumns == 1) {
if (keyCode == ariaDomEvent.KC_ARROW_UP) {
moveFocus--;
}
if (keyCode == ariaDomEvent.KC_ARROW_DOWN) {
moveFocus++;
}
} else {
if (keyCode == ariaDomEvent.KC_ARROW_UP) {
if (flowOrientation == 'vertical') {
moveFocus = focusIndex - 1;
} else {
if (focusIndex - numberOfColumns < 0) {
moveFocus = focusIndex--;
} else {
moveFocus = focusIndex - numberOfColumns;
}
}
} else if (keyCode == ariaDomEvent.KC_ARROW_DOWN) {
if (flowOrientation == 'vertical') {
moveFocus = focusIndex + 1;
} else {
if (numberOfColumns < numberItems - focusIndex) {
moveFocus = focusIndex + numberOfColumns;
} else {
return focusIndex;
}
}
} else if (keyCode == ariaDomEvent.KC_ARROW_LEFT) {
if (flowOrientation == 'horizontal') {
moveFocus = focusIndex - 1;
} else {
if (focusIndex >= numberOfRows) {
moveFocus = focusIndex - numberOfRows;
} else {
return focusIndex;
}
}
} else if (keyCode == ariaDomEvent.KC_ARROW_RIGHT) {
if (flowOrientation == 'horizontal') {
moveFocus = focusIndex + 1;
} else {
if (numberOfColumns < numberItems - focusIndex) {
moveFocus = focusIndex + numberOfRows;
} else {
return focusIndex;
}
}
}
}
if (moveFocus >= numberItems) {
return numberItems - 1;
} else if (moveFocus < 0) {
return 0;
} else {
return moveFocus;
}
}
|
[
"function",
"(",
"flowOrientation",
",",
"focusIndex",
",",
"numberOfRows",
",",
"numberOfColumns",
",",
"keyCode",
",",
"numberItems",
")",
"{",
"var",
"moveFocus",
"=",
"focusIndex",
";",
"if",
"(",
"numberOfColumns",
"==",
"1",
")",
"{",
"if",
"(",
"keyCode",
"==",
"ariaDomEvent",
".",
"KC_ARROW_UP",
")",
"{",
"moveFocus",
"--",
";",
"}",
"if",
"(",
"keyCode",
"==",
"ariaDomEvent",
".",
"KC_ARROW_DOWN",
")",
"{",
"moveFocus",
"++",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"keyCode",
"==",
"ariaDomEvent",
".",
"KC_ARROW_UP",
")",
"{",
"if",
"(",
"flowOrientation",
"==",
"'vertical'",
")",
"{",
"moveFocus",
"=",
"focusIndex",
"-",
"1",
";",
"}",
"else",
"{",
"if",
"(",
"focusIndex",
"-",
"numberOfColumns",
"<",
"0",
")",
"{",
"moveFocus",
"=",
"focusIndex",
"--",
";",
"}",
"else",
"{",
"moveFocus",
"=",
"focusIndex",
"-",
"numberOfColumns",
";",
"}",
"}",
"}",
"else",
"if",
"(",
"keyCode",
"==",
"ariaDomEvent",
".",
"KC_ARROW_DOWN",
")",
"{",
"if",
"(",
"flowOrientation",
"==",
"'vertical'",
")",
"{",
"moveFocus",
"=",
"focusIndex",
"+",
"1",
";",
"}",
"else",
"{",
"if",
"(",
"numberOfColumns",
"<",
"numberItems",
"-",
"focusIndex",
")",
"{",
"moveFocus",
"=",
"focusIndex",
"+",
"numberOfColumns",
";",
"}",
"else",
"{",
"return",
"focusIndex",
";",
"}",
"}",
"}",
"else",
"if",
"(",
"keyCode",
"==",
"ariaDomEvent",
".",
"KC_ARROW_LEFT",
")",
"{",
"if",
"(",
"flowOrientation",
"==",
"'horizontal'",
")",
"{",
"moveFocus",
"=",
"focusIndex",
"-",
"1",
";",
"}",
"else",
"{",
"if",
"(",
"focusIndex",
">=",
"numberOfRows",
")",
"{",
"moveFocus",
"=",
"focusIndex",
"-",
"numberOfRows",
";",
"}",
"else",
"{",
"return",
"focusIndex",
";",
"}",
"}",
"}",
"else",
"if",
"(",
"keyCode",
"==",
"ariaDomEvent",
".",
"KC_ARROW_RIGHT",
")",
"{",
"if",
"(",
"flowOrientation",
"==",
"'horizontal'",
")",
"{",
"moveFocus",
"=",
"focusIndex",
"+",
"1",
";",
"}",
"else",
"{",
"if",
"(",
"numberOfColumns",
"<",
"numberItems",
"-",
"focusIndex",
")",
"{",
"moveFocus",
"=",
"focusIndex",
"+",
"numberOfRows",
";",
"}",
"else",
"{",
"return",
"focusIndex",
";",
"}",
"}",
"}",
"}",
"if",
"(",
"moveFocus",
">=",
"numberItems",
")",
"{",
"return",
"numberItems",
"-",
"1",
";",
"}",
"else",
"if",
"(",
"moveFocus",
"<",
"0",
")",
"{",
"return",
"0",
";",
"}",
"else",
"{",
"return",
"moveFocus",
";",
"}",
"}"
] |
This method calculates which element of the list should have focus after a keypress
@param {String} flowOrientation Whether the items are listed horizonally or vertically
@param {String} focusIndex Which list item is currently focused
@param {String} numberOfRows How many rows are there in the list
@param {String} numberOfColumns How many columns are there in the list
@param {String} keyCode Which key was pressed
@param {String} numberItems How many items are in the list
@returns {Number}
|
[
"This",
"method",
"calculates",
"which",
"element",
"of",
"the",
"list",
"should",
"have",
"focus",
"after",
"a",
"keypress"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/list/ListController.js#L499-L565
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/form/list/ListController.js
|
function (evtInfo) {
var data = this._data;
var evt = {
name : "keyevent",
charCode : evtInfo.charCode,
keyCode : evtInfo.keyCode,
focusIndex : data.focusIndex,
cancelDefault : false
};
this.$raiseEvent(evt);
if (data && !evt.cancelDefault) {
var moveFocus, itemsView = data.itemsView;
if (ariaDomEvent.isNavigationKey(evt.keyCode)) {
this._navigationEvent = true;
var startIndex = data.multipleSelect ? data.focusIndex : data.selectedIndex > -1 ? itemsView.getNewIndex(itemsView.items, data.selectedIndex) : data.selectedIndex, isFocusable = false, oldFocus = startIndex;
moveFocus = startIndex;
while (!isFocusable) {
moveFocus = this.calcMoveFocus(data.displayOptions.flowOrientation, moveFocus, data.numberOfRows, data.numberOfColumns, evt.keyCode, data.itemsView.items.length);
if (oldFocus == moveFocus) {
// Tried to move on to a disabled box that cannot be skipped because it's on the edge of
// the container
moveFocus = startIndex;
isFocusable = true;
} else {
// do not check for single selection as all other are disabled (max item is set to one,
// to be refactored properly, in a way that makes sens)
isFocusable = !data.multipleSelect
|| !itemsView.initialArray[itemsView.items[moveFocus].initIndex].currentlyDisabled;
}
oldFocus = moveFocus;
}
} else {
var moveFocus = data.focusIndex;
}
if (data.multipleSelect) {
evt.cancelDefault = this.setFocusedIndex(moveFocus);
} else if (data.selectedIndex != null) {
this.setSelectedIndex(moveFocus > -1 ? itemsView.items[moveFocus].initIndex : moveFocus);
}
evt.cancelDefault = true;
}
return evt.cancelDefault;
}
|
javascript
|
function (evtInfo) {
var data = this._data;
var evt = {
name : "keyevent",
charCode : evtInfo.charCode,
keyCode : evtInfo.keyCode,
focusIndex : data.focusIndex,
cancelDefault : false
};
this.$raiseEvent(evt);
if (data && !evt.cancelDefault) {
var moveFocus, itemsView = data.itemsView;
if (ariaDomEvent.isNavigationKey(evt.keyCode)) {
this._navigationEvent = true;
var startIndex = data.multipleSelect ? data.focusIndex : data.selectedIndex > -1 ? itemsView.getNewIndex(itemsView.items, data.selectedIndex) : data.selectedIndex, isFocusable = false, oldFocus = startIndex;
moveFocus = startIndex;
while (!isFocusable) {
moveFocus = this.calcMoveFocus(data.displayOptions.flowOrientation, moveFocus, data.numberOfRows, data.numberOfColumns, evt.keyCode, data.itemsView.items.length);
if (oldFocus == moveFocus) {
// Tried to move on to a disabled box that cannot be skipped because it's on the edge of
// the container
moveFocus = startIndex;
isFocusable = true;
} else {
// do not check for single selection as all other are disabled (max item is set to one,
// to be refactored properly, in a way that makes sens)
isFocusable = !data.multipleSelect
|| !itemsView.initialArray[itemsView.items[moveFocus].initIndex].currentlyDisabled;
}
oldFocus = moveFocus;
}
} else {
var moveFocus = data.focusIndex;
}
if (data.multipleSelect) {
evt.cancelDefault = this.setFocusedIndex(moveFocus);
} else if (data.selectedIndex != null) {
this.setSelectedIndex(moveFocus > -1 ? itemsView.items[moveFocus].initIndex : moveFocus);
}
evt.cancelDefault = true;
}
return evt.cancelDefault;
}
|
[
"function",
"(",
"evtInfo",
")",
"{",
"var",
"data",
"=",
"this",
".",
"_data",
";",
"var",
"evt",
"=",
"{",
"name",
":",
"\"keyevent\"",
",",
"charCode",
":",
"evtInfo",
".",
"charCode",
",",
"keyCode",
":",
"evtInfo",
".",
"keyCode",
",",
"focusIndex",
":",
"data",
".",
"focusIndex",
",",
"cancelDefault",
":",
"false",
"}",
";",
"this",
".",
"$raiseEvent",
"(",
"evt",
")",
";",
"if",
"(",
"data",
"&&",
"!",
"evt",
".",
"cancelDefault",
")",
"{",
"var",
"moveFocus",
",",
"itemsView",
"=",
"data",
".",
"itemsView",
";",
"if",
"(",
"ariaDomEvent",
".",
"isNavigationKey",
"(",
"evt",
".",
"keyCode",
")",
")",
"{",
"this",
".",
"_navigationEvent",
"=",
"true",
";",
"var",
"startIndex",
"=",
"data",
".",
"multipleSelect",
"?",
"data",
".",
"focusIndex",
":",
"data",
".",
"selectedIndex",
">",
"-",
"1",
"?",
"itemsView",
".",
"getNewIndex",
"(",
"itemsView",
".",
"items",
",",
"data",
".",
"selectedIndex",
")",
":",
"data",
".",
"selectedIndex",
",",
"isFocusable",
"=",
"false",
",",
"oldFocus",
"=",
"startIndex",
";",
"moveFocus",
"=",
"startIndex",
";",
"while",
"(",
"!",
"isFocusable",
")",
"{",
"moveFocus",
"=",
"this",
".",
"calcMoveFocus",
"(",
"data",
".",
"displayOptions",
".",
"flowOrientation",
",",
"moveFocus",
",",
"data",
".",
"numberOfRows",
",",
"data",
".",
"numberOfColumns",
",",
"evt",
".",
"keyCode",
",",
"data",
".",
"itemsView",
".",
"items",
".",
"length",
")",
";",
"if",
"(",
"oldFocus",
"==",
"moveFocus",
")",
"{",
"moveFocus",
"=",
"startIndex",
";",
"isFocusable",
"=",
"true",
";",
"}",
"else",
"{",
"isFocusable",
"=",
"!",
"data",
".",
"multipleSelect",
"||",
"!",
"itemsView",
".",
"initialArray",
"[",
"itemsView",
".",
"items",
"[",
"moveFocus",
"]",
".",
"initIndex",
"]",
".",
"currentlyDisabled",
";",
"}",
"oldFocus",
"=",
"moveFocus",
";",
"}",
"}",
"else",
"{",
"var",
"moveFocus",
"=",
"data",
".",
"focusIndex",
";",
"}",
"if",
"(",
"data",
".",
"multipleSelect",
")",
"{",
"evt",
".",
"cancelDefault",
"=",
"this",
".",
"setFocusedIndex",
"(",
"moveFocus",
")",
";",
"}",
"else",
"if",
"(",
"data",
".",
"selectedIndex",
"!=",
"null",
")",
"{",
"this",
".",
"setSelectedIndex",
"(",
"moveFocus",
">",
"-",
"1",
"?",
"itemsView",
".",
"items",
"[",
"moveFocus",
"]",
".",
"initIndex",
":",
"moveFocus",
")",
";",
"}",
"evt",
".",
"cancelDefault",
"=",
"true",
";",
"}",
"return",
"evt",
".",
"cancelDefault",
";",
"}"
] |
Notify the list controller that a key has been pressed. The controller reacts by sending a keyevent event.
Upon receiving that event, listeners can either ignore it, which leads to the default action being executed
when returning from the event, or they can override the default action by changing event properties.
@param {Object} Any object with the charCode and keyCode properties which specify which key has been pressed.
Any other property in this object is ignored.
@return {Boolean} cancel state of the event
|
[
"Notify",
"the",
"list",
"controller",
"that",
"a",
"key",
"has",
"been",
"pressed",
".",
"The",
"controller",
"reacts",
"by",
"sending",
"a",
"keyevent",
"event",
".",
"Upon",
"receiving",
"that",
"event",
"listeners",
"can",
"either",
"ignore",
"it",
"which",
"leads",
"to",
"the",
"default",
"action",
"being",
"executed",
"when",
"returning",
"from",
"the",
"event",
"or",
"they",
"can",
"override",
"the",
"default",
"action",
"by",
"changing",
"event",
"properties",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/list/ListController.js#L575-L624
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/form/list/ListController.js
|
function (newValue) {
var data = this._data;
if (newValue == null) {
// a null value is allowed for the selectedIndex property, but it cannot be used to set the property
// as it means several items are selected and we do not know which ones
// just ignore the null value
return;
}
var items = data.items;
if (newValue < 0) {
return false;
} else if (newValue >= items.length) {
return false;
} else {
this.json.setValue(data, "focusIndex", newValue);
this.setFocus(data.focusIndex);
return true;
}
}
|
javascript
|
function (newValue) {
var data = this._data;
if (newValue == null) {
// a null value is allowed for the selectedIndex property, but it cannot be used to set the property
// as it means several items are selected and we do not know which ones
// just ignore the null value
return;
}
var items = data.items;
if (newValue < 0) {
return false;
} else if (newValue >= items.length) {
return false;
} else {
this.json.setValue(data, "focusIndex", newValue);
this.setFocus(data.focusIndex);
return true;
}
}
|
[
"function",
"(",
"newValue",
")",
"{",
"var",
"data",
"=",
"this",
".",
"_data",
";",
"if",
"(",
"newValue",
"==",
"null",
")",
"{",
"return",
";",
"}",
"var",
"items",
"=",
"data",
".",
"items",
";",
"if",
"(",
"newValue",
"<",
"0",
")",
"{",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"newValue",
">=",
"items",
".",
"length",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"this",
".",
"json",
".",
"setValue",
"(",
"data",
",",
"\"focusIndex\"",
",",
"newValue",
")",
";",
"this",
".",
"setFocus",
"(",
"data",
".",
"focusIndex",
")",
";",
"return",
"true",
";",
"}",
"}"
] |
This focuses the correct item in the list based on the item passed
@public
@param {Number} The item number to focus
@returns Boolean
|
[
"This",
"focuses",
"the",
"correct",
"item",
"in",
"the",
"list",
"based",
"on",
"the",
"item",
"passed"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/list/ListController.js#L632-L654
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/form/list/ListController.js
|
function (itemIndex, alreadyChanged) {
var data = this._data;
itemIndex = parseInt(itemIndex, 10); // it will most likely be a string before the conversion
if (isNaN(itemIndex) || itemIndex < 0 || itemIndex > data.items.length) {
return; // ignore wrong values of itemIndex
}
var newIndex;
if (data.itemsView) {
newIndex = this._data.itemsView.getNewIndex(data.itemsView.items, itemIndex);
} else {
newIndex = itemIndex;
}
this.setFocusedIndex(newIndex);
if (alreadyChanged == null) {
alreadyChanged = false;
}
var item = data.items[itemIndex];
var evt = {
name : "itemClick",
index : itemIndex,
item : item,
value : item.value,
alreadyChanged : alreadyChanged
};
this.$raiseEvent(evt);
// Warning: this._data below shouldn't be changed to a local variable as this._data can be disposed in
// some cases and it's needed in toggleSection
if (this._data && !evt.cancelDefault && !alreadyChanged) {
// we check this._data because because in the click event, the list controller
// may have been disposed (e.g. in the selectBox)
this.toggleSelection(itemIndex);
}
}
|
javascript
|
function (itemIndex, alreadyChanged) {
var data = this._data;
itemIndex = parseInt(itemIndex, 10); // it will most likely be a string before the conversion
if (isNaN(itemIndex) || itemIndex < 0 || itemIndex > data.items.length) {
return; // ignore wrong values of itemIndex
}
var newIndex;
if (data.itemsView) {
newIndex = this._data.itemsView.getNewIndex(data.itemsView.items, itemIndex);
} else {
newIndex = itemIndex;
}
this.setFocusedIndex(newIndex);
if (alreadyChanged == null) {
alreadyChanged = false;
}
var item = data.items[itemIndex];
var evt = {
name : "itemClick",
index : itemIndex,
item : item,
value : item.value,
alreadyChanged : alreadyChanged
};
this.$raiseEvent(evt);
// Warning: this._data below shouldn't be changed to a local variable as this._data can be disposed in
// some cases and it's needed in toggleSection
if (this._data && !evt.cancelDefault && !alreadyChanged) {
// we check this._data because because in the click event, the list controller
// may have been disposed (e.g. in the selectBox)
this.toggleSelection(itemIndex);
}
}
|
[
"function",
"(",
"itemIndex",
",",
"alreadyChanged",
")",
"{",
"var",
"data",
"=",
"this",
".",
"_data",
";",
"itemIndex",
"=",
"parseInt",
"(",
"itemIndex",
",",
"10",
")",
";",
"if",
"(",
"isNaN",
"(",
"itemIndex",
")",
"||",
"itemIndex",
"<",
"0",
"||",
"itemIndex",
">",
"data",
".",
"items",
".",
"length",
")",
"{",
"return",
";",
"}",
"var",
"newIndex",
";",
"if",
"(",
"data",
".",
"itemsView",
")",
"{",
"newIndex",
"=",
"this",
".",
"_data",
".",
"itemsView",
".",
"getNewIndex",
"(",
"data",
".",
"itemsView",
".",
"items",
",",
"itemIndex",
")",
";",
"}",
"else",
"{",
"newIndex",
"=",
"itemIndex",
";",
"}",
"this",
".",
"setFocusedIndex",
"(",
"newIndex",
")",
";",
"if",
"(",
"alreadyChanged",
"==",
"null",
")",
"{",
"alreadyChanged",
"=",
"false",
";",
"}",
"var",
"item",
"=",
"data",
".",
"items",
"[",
"itemIndex",
"]",
";",
"var",
"evt",
"=",
"{",
"name",
":",
"\"itemClick\"",
",",
"index",
":",
"itemIndex",
",",
"item",
":",
"item",
",",
"value",
":",
"item",
".",
"value",
",",
"alreadyChanged",
":",
"alreadyChanged",
"}",
";",
"this",
".",
"$raiseEvent",
"(",
"evt",
")",
";",
"if",
"(",
"this",
".",
"_data",
"&&",
"!",
"evt",
".",
"cancelDefault",
"&&",
"!",
"alreadyChanged",
")",
"{",
"this",
".",
"toggleSelection",
"(",
"itemIndex",
")",
";",
"}",
"}"
] |
Called when an item is clicked
@param {String} itemIndex index of the item that was changed
@param {Boolean} alreadyChanged if true the selected property of the item was already changed (so that it is
not necessary to change it again, only raise the itemClick event)
|
[
"Called",
"when",
"an",
"item",
"is",
"clicked"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/list/ListController.js#L670-L708
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/form/list/ListController.js
|
function (itemIndex) {
var data = this._data;
itemIndex = parseInt(itemIndex, 10); // it will most likely be a string before the conversion
if (isNaN(itemIndex) || itemIndex < 0 || itemIndex > data.items.length) {
return; // ignore wrong values of itemIndex
}
var item = data.items[itemIndex];
this._navigationEvent = true;
var evt = {
name : "itemMouseOver",
index : itemIndex,
item : item,
value : item.value
};
this.$raiseEvent(evt);
}
|
javascript
|
function (itemIndex) {
var data = this._data;
itemIndex = parseInt(itemIndex, 10); // it will most likely be a string before the conversion
if (isNaN(itemIndex) || itemIndex < 0 || itemIndex > data.items.length) {
return; // ignore wrong values of itemIndex
}
var item = data.items[itemIndex];
this._navigationEvent = true;
var evt = {
name : "itemMouseOver",
index : itemIndex,
item : item,
value : item.value
};
this.$raiseEvent(evt);
}
|
[
"function",
"(",
"itemIndex",
")",
"{",
"var",
"data",
"=",
"this",
".",
"_data",
";",
"itemIndex",
"=",
"parseInt",
"(",
"itemIndex",
",",
"10",
")",
";",
"if",
"(",
"isNaN",
"(",
"itemIndex",
")",
"||",
"itemIndex",
"<",
"0",
"||",
"itemIndex",
">",
"data",
".",
"items",
".",
"length",
")",
"{",
"return",
";",
"}",
"var",
"item",
"=",
"data",
".",
"items",
"[",
"itemIndex",
"]",
";",
"this",
".",
"_navigationEvent",
"=",
"true",
";",
"var",
"evt",
"=",
"{",
"name",
":",
"\"itemMouseOver\"",
",",
"index",
":",
"itemIndex",
",",
"item",
":",
"item",
",",
"value",
":",
"item",
".",
"value",
"}",
";",
"this",
".",
"$raiseEvent",
"(",
"evt",
")",
";",
"}"
] |
Called when the mouse moves over an item.
@param {String} itemIndex index of the item over which the mouse moved
|
[
"Called",
"when",
"the",
"mouse",
"moves",
"over",
"an",
"item",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/list/ListController.js#L714-L729
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/form/list/ListController.js
|
function (itemIndex) {
// Don't do anything if the widget is disabled
if (!this._data.disabled) {
var newVal = !this._data.items[itemIndex].selected;
this.setSelection(itemIndex, newVal);
return newVal;
} else {
return this._data.items[itemIndex].selected;
}
}
|
javascript
|
function (itemIndex) {
// Don't do anything if the widget is disabled
if (!this._data.disabled) {
var newVal = !this._data.items[itemIndex].selected;
this.setSelection(itemIndex, newVal);
return newVal;
} else {
return this._data.items[itemIndex].selected;
}
}
|
[
"function",
"(",
"itemIndex",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_data",
".",
"disabled",
")",
"{",
"var",
"newVal",
"=",
"!",
"this",
".",
"_data",
".",
"items",
"[",
"itemIndex",
"]",
".",
"selected",
";",
"this",
".",
"setSelection",
"(",
"itemIndex",
",",
"newVal",
")",
";",
"return",
"newVal",
";",
"}",
"else",
"{",
"return",
"this",
".",
"_data",
".",
"items",
"[",
"itemIndex",
"]",
".",
"selected",
";",
"}",
"}"
] |
Toggles the selection of a specific item
@param {Number} itemIndex Index of the item to toggle in the items array in the data model
@return true if item is selected after this call, false if not selected
|
[
"Toggles",
"the",
"selection",
"of",
"a",
"specific",
"item"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/list/ListController.js#L736-L745
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/form/list/ListController.js
|
function (newValues) {
var arrayUtil = ariaUtilsArray;
this._stopUpdates();
var newlySelectedIndexes = [];
var newlyUnselectedIndexes = [];
// Loop through all of the items and update the selection status for each item,
// depending on the new array of selected values
var selectedIndex = -1;
var data = this._data;
var items = data.items;
var maxSelectedCount = this._getTrueMaxSelectedCount(items);
var selectedCount = 0;
for (var idx = 0, length = items.length; idx < length; idx++) {
var item = items[idx];
var selected = arrayUtil.contains(newValues, item.value);
if (selected) {
if (selectedCount == maxSelectedCount) {
// cancel selection when there is more than what is allowed
selected = false;
} else if (selectedIndex == -1) {
selectedCount = 1;
selectedIndex = idx;
} else {
selectedCount++;
selectedIndex = null;
}
}
if (data.preselect === "none" || item.selected != selected) {
// selection has changed
(selected ? newlySelectedIndexes : newlyUnselectedIndexes).push(idx);
this.json.setValue(items[idx], "selected", selected);
}
}
this.json.setValue(data, "selectedIndex", selectedIndex);
this.json.setValue(data, "selectedCount", selectedCount);
// James removed this because if more than one item is selected, data. selectedIndex is set to null.
// Also, in the case of the multi-select we don't necessarily
// Want to focus a selected item - need to check this on the list.
// this.json.setValue(data, "focusIndex", selectedIndex);
// this.setFocus(data.focusIndex);
this._updateCurrentlyDisabled(items);
this._resumeUpdates();
if (newlySelectedIndexes.length > 0 || newlyUnselectedIndexes.length > 0) {
this._raiseOnChangeEvent(newlySelectedIndexes, newlyUnselectedIndexes);
}
}
|
javascript
|
function (newValues) {
var arrayUtil = ariaUtilsArray;
this._stopUpdates();
var newlySelectedIndexes = [];
var newlyUnselectedIndexes = [];
// Loop through all of the items and update the selection status for each item,
// depending on the new array of selected values
var selectedIndex = -1;
var data = this._data;
var items = data.items;
var maxSelectedCount = this._getTrueMaxSelectedCount(items);
var selectedCount = 0;
for (var idx = 0, length = items.length; idx < length; idx++) {
var item = items[idx];
var selected = arrayUtil.contains(newValues, item.value);
if (selected) {
if (selectedCount == maxSelectedCount) {
// cancel selection when there is more than what is allowed
selected = false;
} else if (selectedIndex == -1) {
selectedCount = 1;
selectedIndex = idx;
} else {
selectedCount++;
selectedIndex = null;
}
}
if (data.preselect === "none" || item.selected != selected) {
// selection has changed
(selected ? newlySelectedIndexes : newlyUnselectedIndexes).push(idx);
this.json.setValue(items[idx], "selected", selected);
}
}
this.json.setValue(data, "selectedIndex", selectedIndex);
this.json.setValue(data, "selectedCount", selectedCount);
// James removed this because if more than one item is selected, data. selectedIndex is set to null.
// Also, in the case of the multi-select we don't necessarily
// Want to focus a selected item - need to check this on the list.
// this.json.setValue(data, "focusIndex", selectedIndex);
// this.setFocus(data.focusIndex);
this._updateCurrentlyDisabled(items);
this._resumeUpdates();
if (newlySelectedIndexes.length > 0 || newlyUnselectedIndexes.length > 0) {
this._raiseOnChangeEvent(newlySelectedIndexes, newlyUnselectedIndexes);
}
}
|
[
"function",
"(",
"newValues",
")",
"{",
"var",
"arrayUtil",
"=",
"ariaUtilsArray",
";",
"this",
".",
"_stopUpdates",
"(",
")",
";",
"var",
"newlySelectedIndexes",
"=",
"[",
"]",
";",
"var",
"newlyUnselectedIndexes",
"=",
"[",
"]",
";",
"var",
"selectedIndex",
"=",
"-",
"1",
";",
"var",
"data",
"=",
"this",
".",
"_data",
";",
"var",
"items",
"=",
"data",
".",
"items",
";",
"var",
"maxSelectedCount",
"=",
"this",
".",
"_getTrueMaxSelectedCount",
"(",
"items",
")",
";",
"var",
"selectedCount",
"=",
"0",
";",
"for",
"(",
"var",
"idx",
"=",
"0",
",",
"length",
"=",
"items",
".",
"length",
";",
"idx",
"<",
"length",
";",
"idx",
"++",
")",
"{",
"var",
"item",
"=",
"items",
"[",
"idx",
"]",
";",
"var",
"selected",
"=",
"arrayUtil",
".",
"contains",
"(",
"newValues",
",",
"item",
".",
"value",
")",
";",
"if",
"(",
"selected",
")",
"{",
"if",
"(",
"selectedCount",
"==",
"maxSelectedCount",
")",
"{",
"selected",
"=",
"false",
";",
"}",
"else",
"if",
"(",
"selectedIndex",
"==",
"-",
"1",
")",
"{",
"selectedCount",
"=",
"1",
";",
"selectedIndex",
"=",
"idx",
";",
"}",
"else",
"{",
"selectedCount",
"++",
";",
"selectedIndex",
"=",
"null",
";",
"}",
"}",
"if",
"(",
"data",
".",
"preselect",
"===",
"\"none\"",
"||",
"item",
".",
"selected",
"!=",
"selected",
")",
"{",
"(",
"selected",
"?",
"newlySelectedIndexes",
":",
"newlyUnselectedIndexes",
")",
".",
"push",
"(",
"idx",
")",
";",
"this",
".",
"json",
".",
"setValue",
"(",
"items",
"[",
"idx",
"]",
",",
"\"selected\"",
",",
"selected",
")",
";",
"}",
"}",
"this",
".",
"json",
".",
"setValue",
"(",
"data",
",",
"\"selectedIndex\"",
",",
"selectedIndex",
")",
";",
"this",
".",
"json",
".",
"setValue",
"(",
"data",
",",
"\"selectedCount\"",
",",
"selectedCount",
")",
";",
"this",
".",
"_updateCurrentlyDisabled",
"(",
"items",
")",
";",
"this",
".",
"_resumeUpdates",
"(",
")",
";",
"if",
"(",
"newlySelectedIndexes",
".",
"length",
">",
"0",
"||",
"newlyUnselectedIndexes",
".",
"length",
">",
"0",
")",
"{",
"this",
".",
"_raiseOnChangeEvent",
"(",
"newlySelectedIndexes",
",",
"newlyUnselectedIndexes",
")",
";",
"}",
"}"
] |
Set the list of selected values.
@param {Array} newValues
|
[
"Set",
"the",
"list",
"of",
"selected",
"values",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/list/ListController.js#L760-L809
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/form/list/ListController.js
|
function (newValue) {
if (newValue == null) {
// a null value is allowed for the selectedIndex property, but it cannot be used to set the property
// as it means several items are selected and we do not know which ones
// just ignore the null value
return;
}
var items = this._data.items;
if (newValue < 0 || newValue >= items.length) {
// unselect all values in case newValue is -1 or invalid
this.setSelectedValues([]);
} else {
this.setSelectedValues([items[newValue].value]);
}
}
|
javascript
|
function (newValue) {
if (newValue == null) {
// a null value is allowed for the selectedIndex property, but it cannot be used to set the property
// as it means several items are selected and we do not know which ones
// just ignore the null value
return;
}
var items = this._data.items;
if (newValue < 0 || newValue >= items.length) {
// unselect all values in case newValue is -1 or invalid
this.setSelectedValues([]);
} else {
this.setSelectedValues([items[newValue].value]);
}
}
|
[
"function",
"(",
"newValue",
")",
"{",
"if",
"(",
"newValue",
"==",
"null",
")",
"{",
"return",
";",
"}",
"var",
"items",
"=",
"this",
".",
"_data",
".",
"items",
";",
"if",
"(",
"newValue",
"<",
"0",
"||",
"newValue",
">=",
"items",
".",
"length",
")",
"{",
"this",
".",
"setSelectedValues",
"(",
"[",
"]",
")",
";",
"}",
"else",
"{",
"this",
".",
"setSelectedValues",
"(",
"[",
"items",
"[",
"newValue",
"]",
".",
"value",
"]",
")",
";",
"}",
"}"
] |
Set the selected index.
@param {Number} newValue
|
[
"Set",
"the",
"selected",
"index",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/list/ListController.js#L815-L829
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/form/list/ListController.js
|
function () {
var data = this._data;
if (data.selectedIndex == -1) {
// no item is selected
return [];
} else if (data.selectedIndex != null) {
return [data.selectedIndex];
} else {
var retVal = [];
// we iterate over the view, so that we return indexes in the order visible to the user:
var view = data.itemsView;
view.refresh(); // in case there are changes in the view, refresh it
var items = view.items;
for (var idx = 0, length = items.length; idx < length; idx++) {
if (items[idx].value.selected) {
// retVal.push(idx);
retVal.push(items[idx].initIndex);
}
}
return retVal;
}
}
|
javascript
|
function () {
var data = this._data;
if (data.selectedIndex == -1) {
// no item is selected
return [];
} else if (data.selectedIndex != null) {
return [data.selectedIndex];
} else {
var retVal = [];
// we iterate over the view, so that we return indexes in the order visible to the user:
var view = data.itemsView;
view.refresh(); // in case there are changes in the view, refresh it
var items = view.items;
for (var idx = 0, length = items.length; idx < length; idx++) {
if (items[idx].value.selected) {
// retVal.push(idx);
retVal.push(items[idx].initIndex);
}
}
return retVal;
}
}
|
[
"function",
"(",
")",
"{",
"var",
"data",
"=",
"this",
".",
"_data",
";",
"if",
"(",
"data",
".",
"selectedIndex",
"==",
"-",
"1",
")",
"{",
"return",
"[",
"]",
";",
"}",
"else",
"if",
"(",
"data",
".",
"selectedIndex",
"!=",
"null",
")",
"{",
"return",
"[",
"data",
".",
"selectedIndex",
"]",
";",
"}",
"else",
"{",
"var",
"retVal",
"=",
"[",
"]",
";",
"var",
"view",
"=",
"data",
".",
"itemsView",
";",
"view",
".",
"refresh",
"(",
")",
";",
"var",
"items",
"=",
"view",
".",
"items",
";",
"for",
"(",
"var",
"idx",
"=",
"0",
",",
"length",
"=",
"items",
".",
"length",
";",
"idx",
"<",
"length",
";",
"idx",
"++",
")",
"{",
"if",
"(",
"items",
"[",
"idx",
"]",
".",
"value",
".",
"selected",
")",
"{",
"retVal",
".",
"push",
"(",
"items",
"[",
"idx",
"]",
".",
"initIndex",
")",
";",
"}",
"}",
"return",
"retVal",
";",
"}",
"}"
] |
Get an array of all selected indexes.
@return {Array}
|
[
"Get",
"an",
"array",
"of",
"all",
"selected",
"indexes",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/list/ListController.js#L864-L885
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/form/list/ListController.js
|
function () {
var selectedIndexes = this.getSelectedIndexes();
var retVal = [];
var items = this._data.items;
for (var i = 0, length = selectedIndexes.length; i < length; i++) {
retVal[i] = items[selectedIndexes[i]];
}
return retVal;
}
|
javascript
|
function () {
var selectedIndexes = this.getSelectedIndexes();
var retVal = [];
var items = this._data.items;
for (var i = 0, length = selectedIndexes.length; i < length; i++) {
retVal[i] = items[selectedIndexes[i]];
}
return retVal;
}
|
[
"function",
"(",
")",
"{",
"var",
"selectedIndexes",
"=",
"this",
".",
"getSelectedIndexes",
"(",
")",
";",
"var",
"retVal",
"=",
"[",
"]",
";",
"var",
"items",
"=",
"this",
".",
"_data",
".",
"items",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"length",
"=",
"selectedIndexes",
".",
"length",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"retVal",
"[",
"i",
"]",
"=",
"items",
"[",
"selectedIndexes",
"[",
"i",
"]",
"]",
";",
"}",
"return",
"retVal",
";",
"}"
] |
Gets all selected list items.
@return {Array} An array of all selected items. The items returned are in the internal data model format.
From these items it's possible to get for example label, value and selection data.
|
[
"Gets",
"all",
"selected",
"list",
"items",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/list/ListController.js#L892-L900
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/form/list/ListController.js
|
function (newlySelectedIndexes, newlyUnselectedIndexes) {
var data = this._data;
if (newlySelectedIndexes.length === 0 && data.selectedCount === 0) {
var preselect = this._checkPreselect();
if (preselect != null) {
newlySelectedIndexes = [preselect];
this.json.setValue(data.itemsView.items[preselect].value, "selected", true);
this.json.setValue(data, "selectedIndex", preselect);
this.json.setValue(data, "selectedCount", 1);
}
}
this.$raiseEvent({
name : "onChange",
selectedIndexes : newlySelectedIndexes,
unselectedIndexes : newlyUnselectedIndexes
});
}
|
javascript
|
function (newlySelectedIndexes, newlyUnselectedIndexes) {
var data = this._data;
if (newlySelectedIndexes.length === 0 && data.selectedCount === 0) {
var preselect = this._checkPreselect();
if (preselect != null) {
newlySelectedIndexes = [preselect];
this.json.setValue(data.itemsView.items[preselect].value, "selected", true);
this.json.setValue(data, "selectedIndex", preselect);
this.json.setValue(data, "selectedCount", 1);
}
}
this.$raiseEvent({
name : "onChange",
selectedIndexes : newlySelectedIndexes,
unselectedIndexes : newlyUnselectedIndexes
});
}
|
[
"function",
"(",
"newlySelectedIndexes",
",",
"newlyUnselectedIndexes",
")",
"{",
"var",
"data",
"=",
"this",
".",
"_data",
";",
"if",
"(",
"newlySelectedIndexes",
".",
"length",
"===",
"0",
"&&",
"data",
".",
"selectedCount",
"===",
"0",
")",
"{",
"var",
"preselect",
"=",
"this",
".",
"_checkPreselect",
"(",
")",
";",
"if",
"(",
"preselect",
"!=",
"null",
")",
"{",
"newlySelectedIndexes",
"=",
"[",
"preselect",
"]",
";",
"this",
".",
"json",
".",
"setValue",
"(",
"data",
".",
"itemsView",
".",
"items",
"[",
"preselect",
"]",
".",
"value",
",",
"\"selected\"",
",",
"true",
")",
";",
"this",
".",
"json",
".",
"setValue",
"(",
"data",
",",
"\"selectedIndex\"",
",",
"preselect",
")",
";",
"this",
".",
"json",
".",
"setValue",
"(",
"data",
",",
"\"selectedCount\"",
",",
"1",
")",
";",
"}",
"}",
"this",
".",
"$raiseEvent",
"(",
"{",
"name",
":",
"\"onChange\"",
",",
"selectedIndexes",
":",
"newlySelectedIndexes",
",",
"unselectedIndexes",
":",
"newlyUnselectedIndexes",
"}",
")",
";",
"}"
] |
Raises the onChange event
@protected
@param {Array} newlySelectedIndexes array of newly selected indexes
@param {Array} newlyUnselectedIndexes array of newly unselected indexes
|
[
"Raises",
"the",
"onChange",
"event"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/list/ListController.js#L923-L940
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/form/list/ListController.js
|
function (flowOrientation, numberOfRows, numberOfCols, noItems) {
var numItemsLastCol;
if (flowOrientation == 'vertical') {
if (!numberOfRows) {
if (numberOfCols) {
numberOfRows = Math.ceil(noItems / numberOfCols);
// Now make sure the number of cols they've passed is correct
numberOfCols = Math.ceil(noItems / numberOfRows);
} else {
numberOfCols = 1;
numberOfRows = noItems;
}
} else {
numberOfCols = Math.ceil(noItems / numberOfRows);
numItemsLastCol = noItems % numberOfRows;
}
} else if (flowOrientation == 'horizontal') {
if (!numberOfCols) {
if (numberOfRows) {
numberOfCols = Math.ceil(noItems / numberOfRows);
// Now make sure the number of rows they've passed is correct
numberOfRows = Math.ceil(noItems / numberOfCols);
} else {
numberOfRows = 1;
numberOfCols = noItems;
}
} else {
numberOfRows = Math.ceil(noItems / numberOfCols);
}
}
this.json.setValue(this._data, "numberOfRows", numberOfRows);
this.json.setValue(this._data, "numberOfColumns", numberOfCols);
}
|
javascript
|
function (flowOrientation, numberOfRows, numberOfCols, noItems) {
var numItemsLastCol;
if (flowOrientation == 'vertical') {
if (!numberOfRows) {
if (numberOfCols) {
numberOfRows = Math.ceil(noItems / numberOfCols);
// Now make sure the number of cols they've passed is correct
numberOfCols = Math.ceil(noItems / numberOfRows);
} else {
numberOfCols = 1;
numberOfRows = noItems;
}
} else {
numberOfCols = Math.ceil(noItems / numberOfRows);
numItemsLastCol = noItems % numberOfRows;
}
} else if (flowOrientation == 'horizontal') {
if (!numberOfCols) {
if (numberOfRows) {
numberOfCols = Math.ceil(noItems / numberOfRows);
// Now make sure the number of rows they've passed is correct
numberOfRows = Math.ceil(noItems / numberOfCols);
} else {
numberOfRows = 1;
numberOfCols = noItems;
}
} else {
numberOfRows = Math.ceil(noItems / numberOfCols);
}
}
this.json.setValue(this._data, "numberOfRows", numberOfRows);
this.json.setValue(this._data, "numberOfColumns", numberOfCols);
}
|
[
"function",
"(",
"flowOrientation",
",",
"numberOfRows",
",",
"numberOfCols",
",",
"noItems",
")",
"{",
"var",
"numItemsLastCol",
";",
"if",
"(",
"flowOrientation",
"==",
"'vertical'",
")",
"{",
"if",
"(",
"!",
"numberOfRows",
")",
"{",
"if",
"(",
"numberOfCols",
")",
"{",
"numberOfRows",
"=",
"Math",
".",
"ceil",
"(",
"noItems",
"/",
"numberOfCols",
")",
";",
"numberOfCols",
"=",
"Math",
".",
"ceil",
"(",
"noItems",
"/",
"numberOfRows",
")",
";",
"}",
"else",
"{",
"numberOfCols",
"=",
"1",
";",
"numberOfRows",
"=",
"noItems",
";",
"}",
"}",
"else",
"{",
"numberOfCols",
"=",
"Math",
".",
"ceil",
"(",
"noItems",
"/",
"numberOfRows",
")",
";",
"numItemsLastCol",
"=",
"noItems",
"%",
"numberOfRows",
";",
"}",
"}",
"else",
"if",
"(",
"flowOrientation",
"==",
"'horizontal'",
")",
"{",
"if",
"(",
"!",
"numberOfCols",
")",
"{",
"if",
"(",
"numberOfRows",
")",
"{",
"numberOfCols",
"=",
"Math",
".",
"ceil",
"(",
"noItems",
"/",
"numberOfRows",
")",
";",
"numberOfRows",
"=",
"Math",
".",
"ceil",
"(",
"noItems",
"/",
"numberOfCols",
")",
";",
"}",
"else",
"{",
"numberOfRows",
"=",
"1",
";",
"numberOfCols",
"=",
"noItems",
";",
"}",
"}",
"else",
"{",
"numberOfRows",
"=",
"Math",
".",
"ceil",
"(",
"noItems",
"/",
"numberOfCols",
")",
";",
"}",
"}",
"this",
".",
"json",
".",
"setValue",
"(",
"this",
".",
"_data",
",",
"\"numberOfRows\"",
",",
"numberOfRows",
")",
";",
"this",
".",
"json",
".",
"setValue",
"(",
"this",
".",
"_data",
",",
"\"numberOfColumns\"",
",",
"numberOfCols",
")",
";",
"}"
] |
Calculates the number of columns and rows a list should have based on the flow
@protected
@param {String} flowOrientation Orientation of list whether 'horizontal' or 'verticle'
@param {Number} numberOfRows The number of Rows
@param {Number} numberOfCols The number of Columns
@param {Number} noItems The number of Items
|
[
"Calculates",
"the",
"number",
"of",
"columns",
"and",
"rows",
"a",
"list",
"should",
"have",
"based",
"on",
"the",
"flow"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/list/ListController.js#L950-L986
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/form/list/ListController.js
|
function () {
var selected = [];
var items = this._data.items;
for (var i = 0; i < items.length; i++) {
if (!items[i].initiallyDisabled) {
selected.push(items[i].value);
}
}
this.setSelectedValues(selected);
if (this._data) {
this.json.setValue(this._data, "focusIndex", 0);
}
}
|
javascript
|
function () {
var selected = [];
var items = this._data.items;
for (var i = 0; i < items.length; i++) {
if (!items[i].initiallyDisabled) {
selected.push(items[i].value);
}
}
this.setSelectedValues(selected);
if (this._data) {
this.json.setValue(this._data, "focusIndex", 0);
}
}
|
[
"function",
"(",
")",
"{",
"var",
"selected",
"=",
"[",
"]",
";",
"var",
"items",
"=",
"this",
".",
"_data",
".",
"items",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"items",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"items",
"[",
"i",
"]",
".",
"initiallyDisabled",
")",
"{",
"selected",
".",
"push",
"(",
"items",
"[",
"i",
"]",
".",
"value",
")",
";",
"}",
"}",
"this",
".",
"setSelectedValues",
"(",
"selected",
")",
";",
"if",
"(",
"this",
".",
"_data",
")",
"{",
"this",
".",
"json",
".",
"setValue",
"(",
"this",
".",
"_data",
",",
"\"focusIndex\"",
",",
"0",
")",
";",
"}",
"}"
] |
Selects all values in order that they are stored in the datamodel. If any values are initially disabled they
will not be selected. If a value becomes disabled due to the maxOptions constraint then they will not be
selected.
|
[
"Selects",
"all",
"values",
"in",
"order",
"that",
"they",
"are",
"stored",
"in",
"the",
"datamodel",
".",
"If",
"any",
"values",
"are",
"initially",
"disabled",
"they",
"will",
"not",
"be",
"selected",
".",
"If",
"a",
"value",
"becomes",
"disabled",
"due",
"to",
"the",
"maxOptions",
"constraint",
"then",
"they",
"will",
"not",
"be",
"selected",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/list/ListController.js#L1010-L1022
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/core/DownloadMgr.js
|
function (url, force) {
if (force || this._timestampURL[url]) {
var timestamp = (new Date()).getTime();
if (url.indexOf("?") != -1) {
return url + "×tamp=" + timestamp;
} else {
return url + "?timestamp=" + timestamp;
}
} else {
return url;
}
}
|
javascript
|
function (url, force) {
if (force || this._timestampURL[url]) {
var timestamp = (new Date()).getTime();
if (url.indexOf("?") != -1) {
return url + "×tamp=" + timestamp;
} else {
return url + "?timestamp=" + timestamp;
}
} else {
return url;
}
}
|
[
"function",
"(",
"url",
",",
"force",
")",
"{",
"if",
"(",
"force",
"||",
"this",
".",
"_timestampURL",
"[",
"url",
"]",
")",
"{",
"var",
"timestamp",
"=",
"(",
"new",
"Date",
"(",
")",
")",
".",
"getTime",
"(",
")",
";",
"if",
"(",
"url",
".",
"indexOf",
"(",
"\"?\"",
")",
"!=",
"-",
"1",
")",
"{",
"return",
"url",
"+",
"\"×tamp=\"",
"+",
"timestamp",
";",
"}",
"else",
"{",
"return",
"url",
"+",
"\"?timestamp=\"",
"+",
"timestamp",
";",
"}",
"}",
"else",
"{",
"return",
"url",
";",
"}",
"}"
] |
Add a timestamp to the given URL if it should bypass browser cache.
@param {String} url URL for which a timestamp should be added if necessary
@param {Boolean} force if true, the timestamp will always be added
@return {String} URL with the added timestamp if this is required
|
[
"Add",
"a",
"timestamp",
"to",
"the",
"given",
"URL",
"if",
"it",
"should",
"bypass",
"browser",
"cache",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/DownloadMgr.js#L142-L153
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/core/DownloadMgr.js
|
function (urls) {
if (this._typeUtils.isString(urls)) {
urls = [urls];
}
var _getPackages = function (urls, urlMap, packages) {
if (urls.length === 0) {
// everything has been found, leave back the recursive loop
return;
}
for (var key in urlMap) {
var value = urlMap[key];
if (typeof(value) == 'string') {
value = "/" + value;
// Check if something match
for (var i = 0, ii = urls.length; i < ii; i++) {
var file = urls[i];
if (value.substr(0, file.length) == file) {
packages[value] = true;
// remove found item from the url list, for performance reason
urls.slice(i, i);
break;
}
}
} else {
_getPackages(urls, urlMap[key], packages);
}
}
};
// Clone urls array
var urlClone = [];
for (var i = 0, ii = urls.length; i < ii; i++) {
urlClone.push(urls[i]);
}
var packages = {};
_getPackages(urls, this._urlMap, packages);
// return the keys only
var keys = [];
for (var key in packages) {
keys.push(key);
}
return keys;
}
|
javascript
|
function (urls) {
if (this._typeUtils.isString(urls)) {
urls = [urls];
}
var _getPackages = function (urls, urlMap, packages) {
if (urls.length === 0) {
// everything has been found, leave back the recursive loop
return;
}
for (var key in urlMap) {
var value = urlMap[key];
if (typeof(value) == 'string') {
value = "/" + value;
// Check if something match
for (var i = 0, ii = urls.length; i < ii; i++) {
var file = urls[i];
if (value.substr(0, file.length) == file) {
packages[value] = true;
// remove found item from the url list, for performance reason
urls.slice(i, i);
break;
}
}
} else {
_getPackages(urls, urlMap[key], packages);
}
}
};
// Clone urls array
var urlClone = [];
for (var i = 0, ii = urls.length; i < ii; i++) {
urlClone.push(urls[i]);
}
var packages = {};
_getPackages(urls, this._urlMap, packages);
// return the keys only
var keys = [];
for (var key in packages) {
keys.push(key);
}
return keys;
}
|
[
"function",
"(",
"urls",
")",
"{",
"if",
"(",
"this",
".",
"_typeUtils",
".",
"isString",
"(",
"urls",
")",
")",
"{",
"urls",
"=",
"[",
"urls",
"]",
";",
"}",
"var",
"_getPackages",
"=",
"function",
"(",
"urls",
",",
"urlMap",
",",
"packages",
")",
"{",
"if",
"(",
"urls",
".",
"length",
"===",
"0",
")",
"{",
"return",
";",
"}",
"for",
"(",
"var",
"key",
"in",
"urlMap",
")",
"{",
"var",
"value",
"=",
"urlMap",
"[",
"key",
"]",
";",
"if",
"(",
"typeof",
"(",
"value",
")",
"==",
"'string'",
")",
"{",
"value",
"=",
"\"/\"",
"+",
"value",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"ii",
"=",
"urls",
".",
"length",
";",
"i",
"<",
"ii",
";",
"i",
"++",
")",
"{",
"var",
"file",
"=",
"urls",
"[",
"i",
"]",
";",
"if",
"(",
"value",
".",
"substr",
"(",
"0",
",",
"file",
".",
"length",
")",
"==",
"file",
")",
"{",
"packages",
"[",
"value",
"]",
"=",
"true",
";",
"urls",
".",
"slice",
"(",
"i",
",",
"i",
")",
";",
"break",
";",
"}",
"}",
"}",
"else",
"{",
"_getPackages",
"(",
"urls",
",",
"urlMap",
"[",
"key",
"]",
",",
"packages",
")",
";",
"}",
"}",
"}",
";",
"var",
"urlClone",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"ii",
"=",
"urls",
".",
"length",
";",
"i",
"<",
"ii",
";",
"i",
"++",
")",
"{",
"urlClone",
".",
"push",
"(",
"urls",
"[",
"i",
"]",
")",
";",
"}",
"var",
"packages",
"=",
"{",
"}",
";",
"_getPackages",
"(",
"urls",
",",
"this",
".",
"_urlMap",
",",
"packages",
")",
";",
"var",
"keys",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"key",
"in",
"packages",
")",
"{",
"keys",
".",
"push",
"(",
"key",
")",
";",
"}",
"return",
"keys",
";",
"}"
] |
Return an url list from an array containing the starting url, this function is usefull to retrieve package
name with md5 from the name without it
@param {String|Array} urls starting url string
@return {Array} array of full url
|
[
"Return",
"an",
"url",
"list",
"from",
"an",
"array",
"containing",
"the",
"starting",
"url",
"this",
"function",
"is",
"usefull",
"to",
"retrieve",
"package",
"name",
"with",
"md5",
"from",
"the",
"name",
"without",
"it"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/DownloadMgr.js#L161-L207
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/core/DownloadMgr.js
|
function (map, pathparts, doubleStar) {
for (var i = 0, l = pathparts.length; i < l; i++) {
var part = pathparts[i];
if (!this._typeUtils.isObject(map) || this._typeUtils.isInstanceOf(map, 'aria.core.JsObject')) {
break;
}
if (!map[part]) {
if (doubleStar) {
if (map['*'] && i == l - 1) {
map = map['*'];
} else {
map = map['**'];
}
} else {
map = map['*'];
}
break;
}
map = map[part];
}
return {
node : map,
index : i
};
}
|
javascript
|
function (map, pathparts, doubleStar) {
for (var i = 0, l = pathparts.length; i < l; i++) {
var part = pathparts[i];
if (!this._typeUtils.isObject(map) || this._typeUtils.isInstanceOf(map, 'aria.core.JsObject')) {
break;
}
if (!map[part]) {
if (doubleStar) {
if (map['*'] && i == l - 1) {
map = map['*'];
} else {
map = map['**'];
}
} else {
map = map['*'];
}
break;
}
map = map[part];
}
return {
node : map,
index : i
};
}
|
[
"function",
"(",
"map",
",",
"pathparts",
",",
"doubleStar",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"pathparts",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"var",
"part",
"=",
"pathparts",
"[",
"i",
"]",
";",
"if",
"(",
"!",
"this",
".",
"_typeUtils",
".",
"isObject",
"(",
"map",
")",
"||",
"this",
".",
"_typeUtils",
".",
"isInstanceOf",
"(",
"map",
",",
"'aria.core.JsObject'",
")",
")",
"{",
"break",
";",
"}",
"if",
"(",
"!",
"map",
"[",
"part",
"]",
")",
"{",
"if",
"(",
"doubleStar",
")",
"{",
"if",
"(",
"map",
"[",
"'*'",
"]",
"&&",
"i",
"==",
"l",
"-",
"1",
")",
"{",
"map",
"=",
"map",
"[",
"'*'",
"]",
";",
"}",
"else",
"{",
"map",
"=",
"map",
"[",
"'**'",
"]",
";",
"}",
"}",
"else",
"{",
"map",
"=",
"map",
"[",
"'*'",
"]",
";",
"}",
"break",
";",
"}",
"map",
"=",
"map",
"[",
"part",
"]",
";",
"}",
"return",
"{",
"node",
":",
"map",
",",
"index",
":",
"i",
"}",
";",
"}"
] |
Find node associated to a path in a map. May be a string, an object, a function or a instance of callback, or
null.
@protected
@param {Object} map
@param {Array} pathparts
@param {Boolean} doubleStar support double star ** notation
@return {Object} node and index in path
|
[
"Find",
"node",
"associated",
"to",
"a",
"path",
"in",
"a",
"map",
".",
"May",
"be",
"a",
"string",
"an",
"object",
"a",
"function",
"or",
"a",
"instance",
"of",
"callback",
"or",
"null",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/DownloadMgr.js#L323-L348
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/core/DownloadMgr.js
|
function (evt) {
var loader = evt.src, cache = this._cache, itm, lps = loader.getLogicalPaths();
if (lps) {
// remove loader ref from all 'files' entries
var sz = lps.length;
for (var i = 0; sz > i; i++) {
itm = cache.getItem("files", lps[i], false);
if (itm) {
this.$assert(120, itm.loader == loader);
itm.loader = null;
}
}
}
// remove entry from "urls" category
itm = cache.getItem("urls", loader.getURL(), false);
if (itm) {
this.$assert(128, itm.loader == loader);
itm.loader = null;
itm.status = this._cache.STATUS_AVAILABLE;
}
// dispose
loader.$dispose();
}
|
javascript
|
function (evt) {
var loader = evt.src, cache = this._cache, itm, lps = loader.getLogicalPaths();
if (lps) {
// remove loader ref from all 'files' entries
var sz = lps.length;
for (var i = 0; sz > i; i++) {
itm = cache.getItem("files", lps[i], false);
if (itm) {
this.$assert(120, itm.loader == loader);
itm.loader = null;
}
}
}
// remove entry from "urls" category
itm = cache.getItem("urls", loader.getURL(), false);
if (itm) {
this.$assert(128, itm.loader == loader);
itm.loader = null;
itm.status = this._cache.STATUS_AVAILABLE;
}
// dispose
loader.$dispose();
}
|
[
"function",
"(",
"evt",
")",
"{",
"var",
"loader",
"=",
"evt",
".",
"src",
",",
"cache",
"=",
"this",
".",
"_cache",
",",
"itm",
",",
"lps",
"=",
"loader",
".",
"getLogicalPaths",
"(",
")",
";",
"if",
"(",
"lps",
")",
"{",
"var",
"sz",
"=",
"lps",
".",
"length",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"sz",
">",
"i",
";",
"i",
"++",
")",
"{",
"itm",
"=",
"cache",
".",
"getItem",
"(",
"\"files\"",
",",
"lps",
"[",
"i",
"]",
",",
"false",
")",
";",
"if",
"(",
"itm",
")",
"{",
"this",
".",
"$assert",
"(",
"120",
",",
"itm",
".",
"loader",
"==",
"loader",
")",
";",
"itm",
".",
"loader",
"=",
"null",
";",
"}",
"}",
"}",
"itm",
"=",
"cache",
".",
"getItem",
"(",
"\"urls\"",
",",
"loader",
".",
"getURL",
"(",
")",
",",
"false",
")",
";",
"if",
"(",
"itm",
")",
"{",
"this",
".",
"$assert",
"(",
"128",
",",
"itm",
".",
"loader",
"==",
"loader",
")",
";",
"itm",
".",
"loader",
"=",
"null",
";",
"itm",
".",
"status",
"=",
"this",
".",
"_cache",
".",
"STATUS_AVAILABLE",
";",
"}",
"loader",
".",
"$dispose",
"(",
")",
";",
"}"
] |
Internal method called when a file loader can be disposed
@param {aria.core.FileLoader:complete:event} evt
@private
|
[
"Internal",
"method",
"called",
"when",
"a",
"file",
"loader",
"can",
"be",
"disposed"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/DownloadMgr.js#L401-L423
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/core/DownloadMgr.js
|
function (logicalPath, content, hasErrors) {
var itm = this._cache.getItem("files", logicalPath, true);
if (hasErrors) {
itm.status = this._cache.STATUS_ERROR;
} else {
itm.value = content;
itm.status = this._cache.STATUS_AVAILABLE;
}
if (this.lastLoadedFiles) {
this.lastLoadedFiles[logicalPath] = 1;
}
}
|
javascript
|
function (logicalPath, content, hasErrors) {
var itm = this._cache.getItem("files", logicalPath, true);
if (hasErrors) {
itm.status = this._cache.STATUS_ERROR;
} else {
itm.value = content;
itm.status = this._cache.STATUS_AVAILABLE;
}
if (this.lastLoadedFiles) {
this.lastLoadedFiles[logicalPath] = 1;
}
}
|
[
"function",
"(",
"logicalPath",
",",
"content",
",",
"hasErrors",
")",
"{",
"var",
"itm",
"=",
"this",
".",
"_cache",
".",
"getItem",
"(",
"\"files\"",
",",
"logicalPath",
",",
"true",
")",
";",
"if",
"(",
"hasErrors",
")",
"{",
"itm",
".",
"status",
"=",
"this",
".",
"_cache",
".",
"STATUS_ERROR",
";",
"}",
"else",
"{",
"itm",
".",
"value",
"=",
"content",
";",
"itm",
".",
"status",
"=",
"this",
".",
"_cache",
".",
"STATUS_AVAILABLE",
";",
"}",
"if",
"(",
"this",
".",
"lastLoadedFiles",
")",
"{",
"this",
".",
"lastLoadedFiles",
"[",
"logicalPath",
"]",
"=",
"1",
";",
"}",
"}"
] |
Function called by a file loader when a file content has been retrieved
@param {String} logicalPath the logical path of the file
@param {String} content the file content
|
[
"Function",
"called",
"by",
"a",
"file",
"loader",
"when",
"a",
"file",
"content",
"has",
"been",
"retrieved"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/DownloadMgr.js#L430-L441
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/core/DownloadMgr.js
|
function (logicalPath) {
var itm = this._cache.getItem("files", logicalPath, false);
if (itm && itm.status == this._cache.STATUS_AVAILABLE) {
return itm.value;
}
return null;
}
|
javascript
|
function (logicalPath) {
var itm = this._cache.getItem("files", logicalPath, false);
if (itm && itm.status == this._cache.STATUS_AVAILABLE) {
return itm.value;
}
return null;
}
|
[
"function",
"(",
"logicalPath",
")",
"{",
"var",
"itm",
"=",
"this",
".",
"_cache",
".",
"getItem",
"(",
"\"files\"",
",",
"logicalPath",
",",
"false",
")",
";",
"if",
"(",
"itm",
"&&",
"itm",
".",
"status",
"==",
"this",
".",
"_cache",
".",
"STATUS_AVAILABLE",
")",
"{",
"return",
"itm",
".",
"value",
";",
"}",
"return",
"null",
";",
"}"
] |
Get the file content from its logical path Return null if file is in error
@param {String} logicalPath
@return {String}
|
[
"Get",
"the",
"file",
"content",
"from",
"its",
"logical",
"path",
"Return",
"null",
"if",
"file",
"is",
"in",
"error"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/DownloadMgr.js#L448-L454
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/core/DownloadMgr.js
|
function (classpath, cb) {
var logicalPath = Aria.getLogicalPath(classpath, ".tpl", true);
this.loadFile(logicalPath, {
fn : this._onTplFileContentReceive,
scope : this,
args : {
origCb : cb
}
}, null);
}
|
javascript
|
function (classpath, cb) {
var logicalPath = Aria.getLogicalPath(classpath, ".tpl", true);
this.loadFile(logicalPath, {
fn : this._onTplFileContentReceive,
scope : this,
args : {
origCb : cb
}
}, null);
}
|
[
"function",
"(",
"classpath",
",",
"cb",
")",
"{",
"var",
"logicalPath",
"=",
"Aria",
".",
"getLogicalPath",
"(",
"classpath",
",",
"\".tpl\"",
",",
"true",
")",
";",
"this",
".",
"loadFile",
"(",
"logicalPath",
",",
"{",
"fn",
":",
"this",
".",
"_onTplFileContentReceive",
",",
"scope",
":",
"this",
",",
"args",
":",
"{",
"origCb",
":",
"cb",
"}",
"}",
",",
"null",
")",
";",
"}"
] |
Gets tpl file content based on its classpath or retrieves it from the cache if it has been already loaded
@param {String} classpath Classpath of the template
@param {aria.core.CfgBeans:Callback} cb Callback to be called after tpl content is downloaded
|
[
"Gets",
"tpl",
"file",
"content",
"based",
"on",
"its",
"classpath",
"or",
"retrieves",
"it",
"from",
"the",
"cache",
"if",
"it",
"has",
"been",
"already",
"loaded"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/DownloadMgr.js#L461-L470
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/core/DownloadMgr.js
|
function (evt, args) {
var res = {
content : null
};
if (evt.downloadFailed) {
res.downloadFailed = evt.downloadFailed;
}
if (evt.logicalPaths.length > 0) {
res.content = this.getFileContent(evt.logicalPaths[0]);
}
this.$callback(args.origCb, res);
}
|
javascript
|
function (evt, args) {
var res = {
content : null
};
if (evt.downloadFailed) {
res.downloadFailed = evt.downloadFailed;
}
if (evt.logicalPaths.length > 0) {
res.content = this.getFileContent(evt.logicalPaths[0]);
}
this.$callback(args.origCb, res);
}
|
[
"function",
"(",
"evt",
",",
"args",
")",
"{",
"var",
"res",
"=",
"{",
"content",
":",
"null",
"}",
";",
"if",
"(",
"evt",
".",
"downloadFailed",
")",
"{",
"res",
".",
"downloadFailed",
"=",
"evt",
".",
"downloadFailed",
";",
"}",
"if",
"(",
"evt",
".",
"logicalPaths",
".",
"length",
">",
"0",
")",
"{",
"res",
".",
"content",
"=",
"this",
".",
"getFileContent",
"(",
"evt",
".",
"logicalPaths",
"[",
"0",
"]",
")",
";",
"}",
"this",
".",
"$callback",
"(",
"args",
".",
"origCb",
",",
"res",
")",
";",
"}"
] |
Internal method called when tpl content is loaded
@param {aria.core.FileLoader:complete:event} evt
@param {Object} args Additonal arguments for the callback {origCb: {JSON callback} orignal callback to be
called after file load is complete}
@protected
|
[
"Internal",
"method",
"called",
"when",
"tpl",
"content",
"is",
"loaded"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/DownloadMgr.js#L479-L490
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/core/DownloadMgr.js
|
function (logicalPath, timestampNextTime) {
var content = this._cache.content;
delete content.files[logicalPath];
var url = this.resolveURL(logicalPath);
delete content.urls[url];
if (timestampNextTime) {
this.enableURLTimestamp(url, true); // browser cache will be bypassed next time the file is loaded
}
}
|
javascript
|
function (logicalPath, timestampNextTime) {
var content = this._cache.content;
delete content.files[logicalPath];
var url = this.resolveURL(logicalPath);
delete content.urls[url];
if (timestampNextTime) {
this.enableURLTimestamp(url, true); // browser cache will be bypassed next time the file is loaded
}
}
|
[
"function",
"(",
"logicalPath",
",",
"timestampNextTime",
")",
"{",
"var",
"content",
"=",
"this",
".",
"_cache",
".",
"content",
";",
"delete",
"content",
".",
"files",
"[",
"logicalPath",
"]",
";",
"var",
"url",
"=",
"this",
".",
"resolveURL",
"(",
"logicalPath",
")",
";",
"delete",
"content",
".",
"urls",
"[",
"url",
"]",
";",
"if",
"(",
"timestampNextTime",
")",
"{",
"this",
".",
"enableURLTimestamp",
"(",
"url",
",",
"true",
")",
";",
"}",
"}"
] |
Remove the file content associated with logical path
@param {String} classpath
@param {Boolean} timestampNextTime if true, the next time the logical path is loaded, browser and server
cache will be bypassed by adding a timestamp to the url
|
[
"Remove",
"the",
"file",
"content",
"associated",
"with",
"logical",
"path"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/DownloadMgr.js#L498-L506
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/core/DownloadMgr.js
|
function (cb, evt) {
if (this._syncLoadCounter < this.MAX_LOAD_STACK) {
this._syncLoadCounter++;
this.$callback(cb, evt);
this._syncLoadCounter--;
} else {
var self = this;
Aria.$global.setTimeout(function () {
self.$callback(cb, evt);
self = cb = evt = null;
}, 0);
}
}
|
javascript
|
function (cb, evt) {
if (this._syncLoadCounter < this.MAX_LOAD_STACK) {
this._syncLoadCounter++;
this.$callback(cb, evt);
this._syncLoadCounter--;
} else {
var self = this;
Aria.$global.setTimeout(function () {
self.$callback(cb, evt);
self = cb = evt = null;
}, 0);
}
}
|
[
"function",
"(",
"cb",
",",
"evt",
")",
"{",
"if",
"(",
"this",
".",
"_syncLoadCounter",
"<",
"this",
".",
"MAX_LOAD_STACK",
")",
"{",
"this",
".",
"_syncLoadCounter",
"++",
";",
"this",
".",
"$callback",
"(",
"cb",
",",
"evt",
")",
";",
"this",
".",
"_syncLoadCounter",
"--",
";",
"}",
"else",
"{",
"var",
"self",
"=",
"this",
";",
"Aria",
".",
"$global",
".",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"self",
".",
"$callback",
"(",
"cb",
",",
"evt",
")",
";",
"self",
"=",
"cb",
"=",
"evt",
"=",
"null",
";",
"}",
",",
"0",
")",
";",
"}",
"}"
] |
It calls the callback provided as argument. The call is synchronous unless the number of synchronous file
loads has exceeded the allowed limit
@protected
@param {aria.core.CfgBeans:Callback} cb Callback
@param {Object} evt Description of a "fileReady" event
|
[
"It",
"calls",
"the",
"callback",
"provided",
"as",
"argument",
".",
"The",
"call",
"is",
"synchronous",
"unless",
"the",
"number",
"of",
"synchronous",
"file",
"loads",
"has",
"exceeded",
"the",
"allowed",
"limit"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/DownloadMgr.js#L515-L527
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/templates/ModuleCtrl.js
|
function (info) {
if (info.step == "CallBegin" && !aria.templates.ModuleCtrl.prototype[info.method]) {
ariaTemplatesRefreshManager.stop();
}
var evt = {
name : "method" + info.step, /*
* info.step contains either CallBegin, CallEnd or Callback
*/
method : info.method
};
this.$raiseEvent(evt);
if (info.step == "CallEnd" && !aria.templates.ModuleCtrl.prototype[info.method]) {
ariaTemplatesRefreshManager.resume();
}
}
|
javascript
|
function (info) {
if (info.step == "CallBegin" && !aria.templates.ModuleCtrl.prototype[info.method]) {
ariaTemplatesRefreshManager.stop();
}
var evt = {
name : "method" + info.step, /*
* info.step contains either CallBegin, CallEnd or Callback
*/
method : info.method
};
this.$raiseEvent(evt);
if (info.step == "CallEnd" && !aria.templates.ModuleCtrl.prototype[info.method]) {
ariaTemplatesRefreshManager.resume();
}
}
|
[
"function",
"(",
"info",
")",
"{",
"if",
"(",
"info",
".",
"step",
"==",
"\"CallBegin\"",
"&&",
"!",
"aria",
".",
"templates",
".",
"ModuleCtrl",
".",
"prototype",
"[",
"info",
".",
"method",
"]",
")",
"{",
"ariaTemplatesRefreshManager",
".",
"stop",
"(",
")",
";",
"}",
"var",
"evt",
"=",
"{",
"name",
":",
"\"method\"",
"+",
"info",
".",
"step",
",",
"method",
":",
"info",
".",
"method",
"}",
";",
"this",
".",
"$raiseEvent",
"(",
"evt",
")",
";",
"if",
"(",
"info",
".",
"step",
"==",
"\"CallEnd\"",
"&&",
"!",
"aria",
".",
"templates",
".",
"ModuleCtrl",
".",
"prototype",
"[",
"info",
".",
"method",
"]",
")",
"{",
"ariaTemplatesRefreshManager",
".",
"resume",
"(",
")",
";",
"}",
"}"
] |
Callback method called each time a method from the public interface is called. It raises the methodCallBegin,
methodCallEnd and methodCallback events.
@param {Object} info Interceptor info.
|
[
"Callback",
"method",
"called",
"each",
"time",
"a",
"method",
"from",
"the",
"public",
"interface",
"is",
"called",
".",
"It",
"raises",
"the",
"methodCallBegin",
"methodCallEnd",
"and",
"methodCallback",
"events",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/templates/ModuleCtrl.js#L177-L192
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/templates/ModuleCtrl.js
|
function (targetService, jsonData, cb, options) {
var typeUtils = ariaUtilsType;
// change cb as an object if a string or a function is passed as a
// callback
if (typeUtils.isString(cb) || typeUtils.isFunction(cb)) {
var ncb = {
fn : cb,
scope : this
};
cb = ncb;
} else if (typeUtils.isObject(cb) && cb.scope == null) {
cb.scope = this; // default scope = this
}
if (!options) {
options = {};
}
var wrapCB = {
fn : this._submitJsonRequestCB,
scope : this,
args : {
cb : cb
}
};
// Request object constructed with all necessary properties
var requestObject = {
moduleName : this.$package,
session : this._session,
actionQueuing : null,
requestHandler : this.$requestHandler,
urlService : this.$urlService,
requestJsonSerializer : this.$requestJsonSerializer,
async : options.async,
timeout : options.timeout,
headers : options.headers
};
if (typeUtils.isString(targetService)) {
requestObject.actionName = targetService;
} else {
requestObject.serviceSpec = targetService;
}
ariaModulesRequestMgr.submitJsonRequest(requestObject, jsonData, wrapCB);
}
|
javascript
|
function (targetService, jsonData, cb, options) {
var typeUtils = ariaUtilsType;
// change cb as an object if a string or a function is passed as a
// callback
if (typeUtils.isString(cb) || typeUtils.isFunction(cb)) {
var ncb = {
fn : cb,
scope : this
};
cb = ncb;
} else if (typeUtils.isObject(cb) && cb.scope == null) {
cb.scope = this; // default scope = this
}
if (!options) {
options = {};
}
var wrapCB = {
fn : this._submitJsonRequestCB,
scope : this,
args : {
cb : cb
}
};
// Request object constructed with all necessary properties
var requestObject = {
moduleName : this.$package,
session : this._session,
actionQueuing : null,
requestHandler : this.$requestHandler,
urlService : this.$urlService,
requestJsonSerializer : this.$requestJsonSerializer,
async : options.async,
timeout : options.timeout,
headers : options.headers
};
if (typeUtils.isString(targetService)) {
requestObject.actionName = targetService;
} else {
requestObject.serviceSpec = targetService;
}
ariaModulesRequestMgr.submitJsonRequest(requestObject, jsonData, wrapCB);
}
|
[
"function",
"(",
"targetService",
",",
"jsonData",
",",
"cb",
",",
"options",
")",
"{",
"var",
"typeUtils",
"=",
"ariaUtilsType",
";",
"if",
"(",
"typeUtils",
".",
"isString",
"(",
"cb",
")",
"||",
"typeUtils",
".",
"isFunction",
"(",
"cb",
")",
")",
"{",
"var",
"ncb",
"=",
"{",
"fn",
":",
"cb",
",",
"scope",
":",
"this",
"}",
";",
"cb",
"=",
"ncb",
";",
"}",
"else",
"if",
"(",
"typeUtils",
".",
"isObject",
"(",
"cb",
")",
"&&",
"cb",
".",
"scope",
"==",
"null",
")",
"{",
"cb",
".",
"scope",
"=",
"this",
";",
"}",
"if",
"(",
"!",
"options",
")",
"{",
"options",
"=",
"{",
"}",
";",
"}",
"var",
"wrapCB",
"=",
"{",
"fn",
":",
"this",
".",
"_submitJsonRequestCB",
",",
"scope",
":",
"this",
",",
"args",
":",
"{",
"cb",
":",
"cb",
"}",
"}",
";",
"var",
"requestObject",
"=",
"{",
"moduleName",
":",
"this",
".",
"$package",
",",
"session",
":",
"this",
".",
"_session",
",",
"actionQueuing",
":",
"null",
",",
"requestHandler",
":",
"this",
".",
"$requestHandler",
",",
"urlService",
":",
"this",
".",
"$urlService",
",",
"requestJsonSerializer",
":",
"this",
".",
"$requestJsonSerializer",
",",
"async",
":",
"options",
".",
"async",
",",
"timeout",
":",
"options",
".",
"timeout",
",",
"headers",
":",
"options",
".",
"headers",
"}",
";",
"if",
"(",
"typeUtils",
".",
"isString",
"(",
"targetService",
")",
")",
"{",
"requestObject",
".",
"actionName",
"=",
"targetService",
";",
"}",
"else",
"{",
"requestObject",
".",
"serviceSpec",
"=",
"targetService",
";",
"}",
"ariaModulesRequestMgr",
".",
"submitJsonRequest",
"(",
"requestObject",
",",
"jsonData",
",",
"wrapCB",
")",
";",
"}"
] |
Submit a JSON Request
@see aria.modules.RequestMgr.
@param {String|Object} targetService, either :
<ul>
<li> the action path - e.g. 'search' or 'search?x=y'. This path will be automatically concatenated to the
module path determined from the class package </li>
<li> a 'service specification' structure, understood by the UrlService implementation</li>
</ul>
@param {Object} jsonData - the data to post to the server
@param {aria.core.CfgBeans:Callback} cb the callback
@param {aria.modules.RequestBeans.SubmitJsonRequestOptions} options object containing options for the
request, such as timeout and headers.
|
[
"Submit",
"a",
"JSON",
"Request"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/templates/ModuleCtrl.js#L208-L251
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/templates/ModuleCtrl.js
|
function (evt, args) {
var smList = this._smList;
if (smList) {
// smList can be null if the module is in the process of being disposed
for (var i = 0, l = smList.length; i < l; i++) {
if (smList[i] == evt.src) {
ariaUtilsArray.removeAt(smList, i);
if (evt.reloadingObject) {
evt.reloadingObject.$onOnce({
"objectLoaded" : {
scope : this,
fn : this.__onSubModuleReloaded
}
});
}
break;
}
}
}
}
|
javascript
|
function (evt, args) {
var smList = this._smList;
if (smList) {
// smList can be null if the module is in the process of being disposed
for (var i = 0, l = smList.length; i < l; i++) {
if (smList[i] == evt.src) {
ariaUtilsArray.removeAt(smList, i);
if (evt.reloadingObject) {
evt.reloadingObject.$onOnce({
"objectLoaded" : {
scope : this,
fn : this.__onSubModuleReloaded
}
});
}
break;
}
}
}
}
|
[
"function",
"(",
"evt",
",",
"args",
")",
"{",
"var",
"smList",
"=",
"this",
".",
"_smList",
";",
"if",
"(",
"smList",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"smList",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"if",
"(",
"smList",
"[",
"i",
"]",
"==",
"evt",
".",
"src",
")",
"{",
"ariaUtilsArray",
".",
"removeAt",
"(",
"smList",
",",
"i",
")",
";",
"if",
"(",
"evt",
".",
"reloadingObject",
")",
"{",
"evt",
".",
"reloadingObject",
".",
"$onOnce",
"(",
"{",
"\"objectLoaded\"",
":",
"{",
"scope",
":",
"this",
",",
"fn",
":",
"this",
".",
"__onSubModuleReloaded",
"}",
"}",
")",
";",
"}",
"break",
";",
"}",
"}",
"}",
"}"
] |
Internal callback called anytime a "beforeDispose" sub-module event is triggered.
@param {Object} evt the event object
@param {Object} args some helpful info - e.g. args.smRef (sub-module reference)
@protected
|
[
"Internal",
"callback",
"called",
"anytime",
"a",
"beforeDispose",
"sub",
"-",
"module",
"event",
"is",
"triggered",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/templates/ModuleCtrl.js#L281-L300
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/templates/ModuleCtrl.js
|
function (smList, cb) {
// sub-module creation is now entirely managed in ModuleCtrlFactory
// simple shortcut for aria.templates.ModuleCtrlFactory.loadSubModules
ariaTemplatesModuleCtrlFactory.__loadSubModules(this, smList, {
fn : this.__onLoadSubModulesComplete,
scope : this,
args : cb
});
}
|
javascript
|
function (smList, cb) {
// sub-module creation is now entirely managed in ModuleCtrlFactory
// simple shortcut for aria.templates.ModuleCtrlFactory.loadSubModules
ariaTemplatesModuleCtrlFactory.__loadSubModules(this, smList, {
fn : this.__onLoadSubModulesComplete,
scope : this,
args : cb
});
}
|
[
"function",
"(",
"smList",
",",
"cb",
")",
"{",
"ariaTemplatesModuleCtrlFactory",
".",
"__loadSubModules",
"(",
"this",
",",
"smList",
",",
"{",
"fn",
":",
"this",
".",
"__onLoadSubModulesComplete",
",",
"scope",
":",
"this",
",",
"args",
":",
"cb",
"}",
")",
";",
"}"
] |
Asynchrously load, create, initialize and reference sub-modules in the module controller and its data model
@param {Array} smList Array of module definition (of type aria.templates.CfgBeans.SubModuleDefinition)
@param {aria.core.CfgBeans:Callback} cb
|
[
"Asynchrously",
"load",
"create",
"initialize",
"and",
"reference",
"sub",
"-",
"modules",
"in",
"the",
"module",
"controller",
"and",
"its",
"data",
"model"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/templates/ModuleCtrl.js#L319-L327
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/templates/ModuleCtrl.js
|
function (res, cb) {
var subModules = res.subModules;
if (subModules && subModules.length > 0) {
if (!this._smList) {
this._smList = [];
}
this._smList = this._smList.concat(res.subModules);
}
this.$callback(cb, res);
}
|
javascript
|
function (res, cb) {
var subModules = res.subModules;
if (subModules && subModules.length > 0) {
if (!this._smList) {
this._smList = [];
}
this._smList = this._smList.concat(res.subModules);
}
this.$callback(cb, res);
}
|
[
"function",
"(",
"res",
",",
"cb",
")",
"{",
"var",
"subModules",
"=",
"res",
".",
"subModules",
";",
"if",
"(",
"subModules",
"&&",
"subModules",
".",
"length",
">",
"0",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_smList",
")",
"{",
"this",
".",
"_smList",
"=",
"[",
"]",
";",
"}",
"this",
".",
"_smList",
"=",
"this",
".",
"_smList",
".",
"concat",
"(",
"res",
".",
"subModules",
")",
";",
"}",
"this",
".",
"$callback",
"(",
"cb",
",",
"res",
")",
";",
"}"
] |
Internal callback method called when all sub-modules requested in loadSubModules have been loaded.
@param {Array} res array of the sub-module public interfaces
@param {aria.core.CfgBeans:Callback} cb callback to be called at the end of this method
@private
|
[
"Internal",
"callback",
"method",
"called",
"when",
"all",
"sub",
"-",
"modules",
"requested",
"in",
"loadSubModules",
"have",
"been",
"loaded",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/templates/ModuleCtrl.js#L335-L344
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/templates/ModuleCtrl.js
|
function (data, merge) {
this.json.inject(data, this._data, merge);
if (this._dataBeanName) {
if (!ariaCoreJsonValidator.normalize({
json : this._data,
beanName : this._dataBeanName
})) {
this.$logError(this.DATA_CONTENT_INVALID, [this._dataBeanName, this.$classpath]);
}
}
}
|
javascript
|
function (data, merge) {
this.json.inject(data, this._data, merge);
if (this._dataBeanName) {
if (!ariaCoreJsonValidator.normalize({
json : this._data,
beanName : this._dataBeanName
})) {
this.$logError(this.DATA_CONTENT_INVALID, [this._dataBeanName, this.$classpath]);
}
}
}
|
[
"function",
"(",
"data",
",",
"merge",
")",
"{",
"this",
".",
"json",
".",
"inject",
"(",
"data",
",",
"this",
".",
"_data",
",",
"merge",
")",
";",
"if",
"(",
"this",
".",
"_dataBeanName",
")",
"{",
"if",
"(",
"!",
"ariaCoreJsonValidator",
".",
"normalize",
"(",
"{",
"json",
":",
"this",
".",
"_data",
",",
"beanName",
":",
"this",
".",
"_dataBeanName",
"}",
")",
")",
"{",
"this",
".",
"$logError",
"(",
"this",
".",
"DATA_CONTENT_INVALID",
",",
"[",
"this",
".",
"_dataBeanName",
",",
"this",
".",
"$classpath",
"]",
")",
";",
"}",
"}",
"}"
] |
Set the data in the dataModel
@param {Object} data the new Data to set
@param {Boolean} merge If true, existing value in this._data will not be overriden
|
[
"Set",
"the",
"data",
"in",
"the",
"dataModel"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/templates/ModuleCtrl.js#L367-L377
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/templates/ModuleCtrl.js
|
function () {
var res = this.__resources;
if (!res) {
var src = this.$resources;
if (src) {
this.__resources = res = {};
for (var itm in src) {
if (src.hasOwnProperty(itm)) {
res[itm] = this[itm];
}
}
}
}
return res;
}
|
javascript
|
function () {
var res = this.__resources;
if (!res) {
var src = this.$resources;
if (src) {
this.__resources = res = {};
for (var itm in src) {
if (src.hasOwnProperty(itm)) {
res[itm] = this[itm];
}
}
}
}
return res;
}
|
[
"function",
"(",
")",
"{",
"var",
"res",
"=",
"this",
".",
"__resources",
";",
"if",
"(",
"!",
"res",
")",
"{",
"var",
"src",
"=",
"this",
".",
"$resources",
";",
"if",
"(",
"src",
")",
"{",
"this",
".",
"__resources",
"=",
"res",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"itm",
"in",
"src",
")",
"{",
"if",
"(",
"src",
".",
"hasOwnProperty",
"(",
"itm",
")",
")",
"{",
"res",
"[",
"itm",
"]",
"=",
"this",
"[",
"itm",
"]",
";",
"}",
"}",
"}",
"}",
"return",
"res",
";",
"}"
] |
MPI method available on all modules in order to retrieve the module resource set
@return {Object} The module resource set
|
[
"MPI",
"method",
"available",
"on",
"all",
"modules",
"in",
"order",
"to",
"retrieve",
"the",
"module",
"resource",
"set"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/templates/ModuleCtrl.js#L383-L397
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/templates/ModuleCtrl.js
|
function (dataToFind) {
if (this._smList) {
var sz = this._smList.length;
for (var i = 0; i < sz; i++) {
var subModule = this._smList[i];
if (subModule && dataToFind == subModule.getData()) {
return subModule;
}
}
}
return this.$publicInterface();
}
|
javascript
|
function (dataToFind) {
if (this._smList) {
var sz = this._smList.length;
for (var i = 0; i < sz; i++) {
var subModule = this._smList[i];
if (subModule && dataToFind == subModule.getData()) {
return subModule;
}
}
}
return this.$publicInterface();
}
|
[
"function",
"(",
"dataToFind",
")",
"{",
"if",
"(",
"this",
".",
"_smList",
")",
"{",
"var",
"sz",
"=",
"this",
".",
"_smList",
".",
"length",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"sz",
";",
"i",
"++",
")",
"{",
"var",
"subModule",
"=",
"this",
".",
"_smList",
"[",
"i",
"]",
";",
"if",
"(",
"subModule",
"&&",
"dataToFind",
"==",
"subModule",
".",
"getData",
"(",
")",
")",
"{",
"return",
"subModule",
";",
"}",
"}",
"}",
"return",
"this",
".",
"$publicInterface",
"(",
")",
";",
"}"
] |
MPI method available on all modules in order to retrieve a sub-module data controller
@param {Object} dataToFind data object which may correspond to the root of a sub-module data controller
@return {Object} the sub-module data controller public interface whose root data model is dataToFind, or
this.$publicInterface() if no sub-module have dataToFind as root data model
|
[
"MPI",
"method",
"available",
"on",
"all",
"modules",
"in",
"order",
"to",
"retrieve",
"a",
"sub",
"-",
"module",
"data",
"controller"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/templates/ModuleCtrl.js#L405-L416
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/templates/ModuleCtrl.js
|
function (session) {
this._session = session;
if (this._smList) {
var sz = this._smList.length;
for (var i = 0; i < sz; i++) {
var subModule = this._smList[i];
if (subModule) {
subModule.setSession(session);
}
}
}
}
|
javascript
|
function (session) {
this._session = session;
if (this._smList) {
var sz = this._smList.length;
for (var i = 0; i < sz; i++) {
var subModule = this._smList[i];
if (subModule) {
subModule.setSession(session);
}
}
}
}
|
[
"function",
"(",
"session",
")",
"{",
"this",
".",
"_session",
"=",
"session",
";",
"if",
"(",
"this",
".",
"_smList",
")",
"{",
"var",
"sz",
"=",
"this",
".",
"_smList",
".",
"length",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"sz",
";",
"i",
"++",
")",
"{",
"var",
"subModule",
"=",
"this",
".",
"_smList",
"[",
"i",
"]",
";",
"if",
"(",
"subModule",
")",
"{",
"subModule",
".",
"setSession",
"(",
"session",
")",
";",
"}",
"}",
"}",
"}"
] |
Set this module and submodules session
@param {Object} session object containing paramName and id, the session id
|
[
"Set",
"this",
"module",
"and",
"submodules",
"session"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/templates/ModuleCtrl.js#L455-L466
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/templates/DomEventWrapper.js
|
function (domEvt) {
var DomWrapper = ariaTemplatesDomElementWrapper;
this.$DomEvent.constructor.call(this, domEvt);
/**
* Wrapper on the HTML element on which the event happened.
* @type aria.templates.DomElementWrapper
*/
this.target = (this.target ? new DomWrapper(this.target) : null);
/**
* Wrapper on the HTML element from/to which the event is directed. (relatedTarget/fromElement/toElement)
* @type aria.templates.DomElementWrapper
*/
this.relatedTarget = (this.relatedTarget ? new DomWrapper(this.relatedTarget) : null);
// bind function to original scope so that "this" is preserved
// Not needed as $DomEvent constructor creates these functions
// this.stopPropagation = aria.utils.Function.bind(domEvt.stopPropagation, domEvt);
// this.preventDefault = aria.utils.Function.bind(domEvt.preventDefault, domEvt);
}
|
javascript
|
function (domEvt) {
var DomWrapper = ariaTemplatesDomElementWrapper;
this.$DomEvent.constructor.call(this, domEvt);
/**
* Wrapper on the HTML element on which the event happened.
* @type aria.templates.DomElementWrapper
*/
this.target = (this.target ? new DomWrapper(this.target) : null);
/**
* Wrapper on the HTML element from/to which the event is directed. (relatedTarget/fromElement/toElement)
* @type aria.templates.DomElementWrapper
*/
this.relatedTarget = (this.relatedTarget ? new DomWrapper(this.relatedTarget) : null);
// bind function to original scope so that "this" is preserved
// Not needed as $DomEvent constructor creates these functions
// this.stopPropagation = aria.utils.Function.bind(domEvt.stopPropagation, domEvt);
// this.preventDefault = aria.utils.Function.bind(domEvt.preventDefault, domEvt);
}
|
[
"function",
"(",
"domEvt",
")",
"{",
"var",
"DomWrapper",
"=",
"ariaTemplatesDomElementWrapper",
";",
"this",
".",
"$DomEvent",
".",
"constructor",
".",
"call",
"(",
"this",
",",
"domEvt",
")",
";",
"this",
".",
"target",
"=",
"(",
"this",
".",
"target",
"?",
"new",
"DomWrapper",
"(",
"this",
".",
"target",
")",
":",
"null",
")",
";",
"this",
".",
"relatedTarget",
"=",
"(",
"this",
".",
"relatedTarget",
"?",
"new",
"DomWrapper",
"(",
"this",
".",
"relatedTarget",
")",
":",
"null",
")",
";",
"}"
] |
Build a DomEventWrapper object.
@param {Object} domEvt DOM event object (passed directly)
|
[
"Build",
"a",
"DomEventWrapper",
"object",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/templates/DomEventWrapper.js#L33-L52
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/storage/EventBus.js
|
function (location, key, value, old, nspace) {
this.$raiseEvent({
name : "change",
location : location,
namespace : nspace,
key : key,
newValue : value,
oldValue : old,
url : Aria.$window.location
});
}
|
javascript
|
function (location, key, value, old, nspace) {
this.$raiseEvent({
name : "change",
location : location,
namespace : nspace,
key : key,
newValue : value,
oldValue : old,
url : Aria.$window.location
});
}
|
[
"function",
"(",
"location",
",",
"key",
",",
"value",
",",
"old",
",",
"nspace",
")",
"{",
"this",
".",
"$raiseEvent",
"(",
"{",
"name",
":",
"\"change\"",
",",
"location",
":",
"location",
",",
"namespace",
":",
"nspace",
",",
"key",
":",
"key",
",",
"newValue",
":",
"value",
",",
"oldValue",
":",
"old",
",",
"url",
":",
"Aria",
".",
"$window",
".",
"location",
"}",
")",
";",
"}"
] |
Notify that a change event happened on a specific storage location
@param {String} location Storage location where the event is happening, i.e. local/session
@param {String} key Id of the value that is changing, null if clear
@param {String} value Value being set, null if removed
@param {String} old Old value being changed, null if newly added
@param {String} nspace Namspace of the storage instance
|
[
"Notify",
"that",
"a",
"change",
"event",
"happened",
"on",
"a",
"specific",
"storage",
"location"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/storage/EventBus.js#L45-L55
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/Icon.js
|
function (out) {
// --------------------------------------------------- destructuring
var cfg = this._cfg;
var icon = cfg.icon;
var tooltip = cfg.tooltip;
var tabIndex = cfg.tabIndex;
var waiAria = cfg.waiAria;
var label = cfg.label;
var role = cfg.role;
var id = this._domId;
var iconInfo = this._iconInfo;
var extraAttributes = this.extraAttributes;
// ------------------------------------------------------ processing
var attributes = [];
function addAttribute(key, value) {
value = '' + value;
value = ariaUtilsString.escapeForHTML(value, {attr: true});
attributes.push(key + '="' + value + '"');
attributes.push(subst('%1="%2"', key, value));
}
// delegationMarkup ------------------------------------------------
var delegateManager = aria.utils.Delegate;
var delegateId = this._delegateId;
if (!delegateId) {
delegateId = delegateManager.add({
fn : this.delegate,
scope : this
});
this._delegateId = delegateId;
}
var delegationMarkup = delegateManager.getMarkup(delegateId);
// icon ------------------------------------------------------------
addAttribute('id', id);
var style = null;
if (!iconInfo.spriteURL && icon) {
var parts = icon.split(":");
var skinclass = parts[0];
var contentKey = parts[1];
var classes = aria.widgets.AriaSkinInterface.getSkinObject("Icon", skinclass, true).content[contentKey];
addAttribute('class', ['xWidget'].concat(classes).join(' '));
} else {
addAttribute('class', this._getIconClasses(iconInfo));
if (tooltip != null && tooltip !== '') {
tooltip = addAttribute('title', tooltip);
}
attributes.push(delegationMarkup);
style = this._getIconStyle(iconInfo);
}
if (tabIndex != null) {
tabIndex = this._calculateTabIndex();
addAttribute('tabindex', tabIndex);
}
if (waiAria && label) {
addAttribute('aria-label', label);
}
if (waiAria && role) {
addAttribute('role', role);
}
if (style) {
addAttribute('style', style);
}
attributes.push(extraAttributes);
attributes = attributes.join(' ');
var markup = '<span ' + attributes + '></span>';
// ---------------------------------------------------------- output
out.write(markup);
}
|
javascript
|
function (out) {
// --------------------------------------------------- destructuring
var cfg = this._cfg;
var icon = cfg.icon;
var tooltip = cfg.tooltip;
var tabIndex = cfg.tabIndex;
var waiAria = cfg.waiAria;
var label = cfg.label;
var role = cfg.role;
var id = this._domId;
var iconInfo = this._iconInfo;
var extraAttributes = this.extraAttributes;
// ------------------------------------------------------ processing
var attributes = [];
function addAttribute(key, value) {
value = '' + value;
value = ariaUtilsString.escapeForHTML(value, {attr: true});
attributes.push(key + '="' + value + '"');
attributes.push(subst('%1="%2"', key, value));
}
// delegationMarkup ------------------------------------------------
var delegateManager = aria.utils.Delegate;
var delegateId = this._delegateId;
if (!delegateId) {
delegateId = delegateManager.add({
fn : this.delegate,
scope : this
});
this._delegateId = delegateId;
}
var delegationMarkup = delegateManager.getMarkup(delegateId);
// icon ------------------------------------------------------------
addAttribute('id', id);
var style = null;
if (!iconInfo.spriteURL && icon) {
var parts = icon.split(":");
var skinclass = parts[0];
var contentKey = parts[1];
var classes = aria.widgets.AriaSkinInterface.getSkinObject("Icon", skinclass, true).content[contentKey];
addAttribute('class', ['xWidget'].concat(classes).join(' '));
} else {
addAttribute('class', this._getIconClasses(iconInfo));
if (tooltip != null && tooltip !== '') {
tooltip = addAttribute('title', tooltip);
}
attributes.push(delegationMarkup);
style = this._getIconStyle(iconInfo);
}
if (tabIndex != null) {
tabIndex = this._calculateTabIndex();
addAttribute('tabindex', tabIndex);
}
if (waiAria && label) {
addAttribute('aria-label', label);
}
if (waiAria && role) {
addAttribute('role', role);
}
if (style) {
addAttribute('style', style);
}
attributes.push(extraAttributes);
attributes = attributes.join(' ');
var markup = '<span ' + attributes + '></span>';
// ---------------------------------------------------------- output
out.write(markup);
}
|
[
"function",
"(",
"out",
")",
"{",
"var",
"cfg",
"=",
"this",
".",
"_cfg",
";",
"var",
"icon",
"=",
"cfg",
".",
"icon",
";",
"var",
"tooltip",
"=",
"cfg",
".",
"tooltip",
";",
"var",
"tabIndex",
"=",
"cfg",
".",
"tabIndex",
";",
"var",
"waiAria",
"=",
"cfg",
".",
"waiAria",
";",
"var",
"label",
"=",
"cfg",
".",
"label",
";",
"var",
"role",
"=",
"cfg",
".",
"role",
";",
"var",
"id",
"=",
"this",
".",
"_domId",
";",
"var",
"iconInfo",
"=",
"this",
".",
"_iconInfo",
";",
"var",
"extraAttributes",
"=",
"this",
".",
"extraAttributes",
";",
"var",
"attributes",
"=",
"[",
"]",
";",
"function",
"addAttribute",
"(",
"key",
",",
"value",
")",
"{",
"value",
"=",
"''",
"+",
"value",
";",
"value",
"=",
"ariaUtilsString",
".",
"escapeForHTML",
"(",
"value",
",",
"{",
"attr",
":",
"true",
"}",
")",
";",
"attributes",
".",
"push",
"(",
"key",
"+",
"'=\"'",
"+",
"value",
"+",
"'\"'",
")",
";",
"attributes",
".",
"push",
"(",
"subst",
"(",
"'%1=\"%2\"'",
",",
"key",
",",
"value",
")",
")",
";",
"}",
"var",
"delegateManager",
"=",
"aria",
".",
"utils",
".",
"Delegate",
";",
"var",
"delegateId",
"=",
"this",
".",
"_delegateId",
";",
"if",
"(",
"!",
"delegateId",
")",
"{",
"delegateId",
"=",
"delegateManager",
".",
"add",
"(",
"{",
"fn",
":",
"this",
".",
"delegate",
",",
"scope",
":",
"this",
"}",
")",
";",
"this",
".",
"_delegateId",
"=",
"delegateId",
";",
"}",
"var",
"delegationMarkup",
"=",
"delegateManager",
".",
"getMarkup",
"(",
"delegateId",
")",
";",
"addAttribute",
"(",
"'id'",
",",
"id",
")",
";",
"var",
"style",
"=",
"null",
";",
"if",
"(",
"!",
"iconInfo",
".",
"spriteURL",
"&&",
"icon",
")",
"{",
"var",
"parts",
"=",
"icon",
".",
"split",
"(",
"\":\"",
")",
";",
"var",
"skinclass",
"=",
"parts",
"[",
"0",
"]",
";",
"var",
"contentKey",
"=",
"parts",
"[",
"1",
"]",
";",
"var",
"classes",
"=",
"aria",
".",
"widgets",
".",
"AriaSkinInterface",
".",
"getSkinObject",
"(",
"\"Icon\"",
",",
"skinclass",
",",
"true",
")",
".",
"content",
"[",
"contentKey",
"]",
";",
"addAttribute",
"(",
"'class'",
",",
"[",
"'xWidget'",
"]",
".",
"concat",
"(",
"classes",
")",
".",
"join",
"(",
"' '",
")",
")",
";",
"}",
"else",
"{",
"addAttribute",
"(",
"'class'",
",",
"this",
".",
"_getIconClasses",
"(",
"iconInfo",
")",
")",
";",
"if",
"(",
"tooltip",
"!=",
"null",
"&&",
"tooltip",
"!==",
"''",
")",
"{",
"tooltip",
"=",
"addAttribute",
"(",
"'title'",
",",
"tooltip",
")",
";",
"}",
"attributes",
".",
"push",
"(",
"delegationMarkup",
")",
";",
"style",
"=",
"this",
".",
"_getIconStyle",
"(",
"iconInfo",
")",
";",
"}",
"if",
"(",
"tabIndex",
"!=",
"null",
")",
"{",
"tabIndex",
"=",
"this",
".",
"_calculateTabIndex",
"(",
")",
";",
"addAttribute",
"(",
"'tabindex'",
",",
"tabIndex",
")",
";",
"}",
"if",
"(",
"waiAria",
"&&",
"label",
")",
"{",
"addAttribute",
"(",
"'aria-label'",
",",
"label",
")",
";",
"}",
"if",
"(",
"waiAria",
"&&",
"role",
")",
"{",
"addAttribute",
"(",
"'role'",
",",
"role",
")",
";",
"}",
"if",
"(",
"style",
")",
"{",
"addAttribute",
"(",
"'style'",
",",
"style",
")",
";",
"}",
"attributes",
".",
"push",
"(",
"extraAttributes",
")",
";",
"attributes",
"=",
"attributes",
".",
"join",
"(",
"' '",
")",
";",
"var",
"markup",
"=",
"'<span '",
"+",
"attributes",
"+",
"'></span>'",
";",
"out",
".",
"write",
"(",
"markup",
")",
";",
"}"
] |
Override widget _widgetMarkup method.
@protected
@override
@param {aria.templates.MarkupWriter} out the html output writer
|
[
"Override",
"widget",
"_widgetMarkup",
"method",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/Icon.js#L79-L171
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/Icon.js
|
function (newIcon) {
// check if initialization was successful
if (!this._iconInfo) {
return;
}
var iconInfo = this._getIconInfo(newIcon);
// check
if (iconInfo) {
var domElt = this.getDom();
domElt.style.cssText = this._getIconStyle(iconInfo);
domElt.className = this._getIconClasses(iconInfo);
}
this._iconInfo = iconInfo;
}
|
javascript
|
function (newIcon) {
// check if initialization was successful
if (!this._iconInfo) {
return;
}
var iconInfo = this._getIconInfo(newIcon);
// check
if (iconInfo) {
var domElt = this.getDom();
domElt.style.cssText = this._getIconStyle(iconInfo);
domElt.className = this._getIconClasses(iconInfo);
}
this._iconInfo = iconInfo;
}
|
[
"function",
"(",
"newIcon",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_iconInfo",
")",
"{",
"return",
";",
"}",
"var",
"iconInfo",
"=",
"this",
".",
"_getIconInfo",
"(",
"newIcon",
")",
";",
"if",
"(",
"iconInfo",
")",
"{",
"var",
"domElt",
"=",
"this",
".",
"getDom",
"(",
")",
";",
"domElt",
".",
"style",
".",
"cssText",
"=",
"this",
".",
"_getIconStyle",
"(",
"iconInfo",
")",
";",
"domElt",
".",
"className",
"=",
"this",
".",
"_getIconClasses",
"(",
"iconInfo",
")",
";",
"}",
"this",
".",
"_iconInfo",
"=",
"iconInfo",
";",
"}"
] |
Change the style to display a different icon.
@param {String} newIcon
|
[
"Change",
"the",
"style",
"to",
"display",
"a",
"different",
"icon",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/Icon.js#L182-L198
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/Icon.js
|
function (icon) {
var iconParts = icon.split(":");
if (iconParts.length !== 2) {
this.$logError(this.ICON_BADLY_FORMATTED, [icon]);
return null;
} else {
var iconInfo = aria.widgets.AriaSkinInterface.getIcon(iconParts[0], iconParts[1]);
if (!iconInfo) {
this.$logError(this.ICON_NOT_FOUND, [icon]);
return null;
}
return iconInfo;
}
}
|
javascript
|
function (icon) {
var iconParts = icon.split(":");
if (iconParts.length !== 2) {
this.$logError(this.ICON_BADLY_FORMATTED, [icon]);
return null;
} else {
var iconInfo = aria.widgets.AriaSkinInterface.getIcon(iconParts[0], iconParts[1]);
if (!iconInfo) {
this.$logError(this.ICON_NOT_FOUND, [icon]);
return null;
}
return iconInfo;
}
}
|
[
"function",
"(",
"icon",
")",
"{",
"var",
"iconParts",
"=",
"icon",
".",
"split",
"(",
"\":\"",
")",
";",
"if",
"(",
"iconParts",
".",
"length",
"!==",
"2",
")",
"{",
"this",
".",
"$logError",
"(",
"this",
".",
"ICON_BADLY_FORMATTED",
",",
"[",
"icon",
"]",
")",
";",
"return",
"null",
";",
"}",
"else",
"{",
"var",
"iconInfo",
"=",
"aria",
".",
"widgets",
".",
"AriaSkinInterface",
".",
"getIcon",
"(",
"iconParts",
"[",
"0",
"]",
",",
"iconParts",
"[",
"1",
"]",
")",
";",
"if",
"(",
"!",
"iconInfo",
")",
"{",
"this",
".",
"$logError",
"(",
"this",
".",
"ICON_NOT_FOUND",
",",
"[",
"icon",
"]",
")",
";",
"return",
"null",
";",
"}",
"return",
"iconInfo",
";",
"}",
"}"
] |
Gets the icon info
@param {String} icon, something like myLib:myIcon
@protected
@return {Object}
|
[
"Gets",
"the",
"icon",
"info"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/Icon.js#L214-L227
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/Icon.js
|
function (iconInfo) {
var cfg = this._cfg;
var vAlign = !cfg.verticalAlign ? "" : "vertical-align: " + cfg.verticalAlign;
var margins = "margin: 0 0 0 0 "; // default value
if (cfg.margins != null && cfg.margins.match(/^(\d+|x) (\d+|x) (\d+|x) (\d+|x)$/)) {
var margArray = cfg.margins.split(" ");
margins = ['margin:', margArray[0], 'px ', margArray[1], 'px ', margArray[2], 'px ', margArray[3],
'px; '].join('');
} else if (iconInfo.margins != null) {
margins = iconInfo.margins;
}
if (cfg.sourceImage) {
return [margins, ';padding:0;background:url(', iconInfo.imageURL, ') no-repeat; width:',
iconInfo.width, 'px;height:', iconInfo.height, 'px;', vAlign].join('');
} else {
return [margins, ';padding:0;background-position:-', iconInfo.iconLeft, 'px -', iconInfo.iconTop,
'px;', vAlign].join('');
}
}
|
javascript
|
function (iconInfo) {
var cfg = this._cfg;
var vAlign = !cfg.verticalAlign ? "" : "vertical-align: " + cfg.verticalAlign;
var margins = "margin: 0 0 0 0 "; // default value
if (cfg.margins != null && cfg.margins.match(/^(\d+|x) (\d+|x) (\d+|x) (\d+|x)$/)) {
var margArray = cfg.margins.split(" ");
margins = ['margin:', margArray[0], 'px ', margArray[1], 'px ', margArray[2], 'px ', margArray[3],
'px; '].join('');
} else if (iconInfo.margins != null) {
margins = iconInfo.margins;
}
if (cfg.sourceImage) {
return [margins, ';padding:0;background:url(', iconInfo.imageURL, ') no-repeat; width:',
iconInfo.width, 'px;height:', iconInfo.height, 'px;', vAlign].join('');
} else {
return [margins, ';padding:0;background-position:-', iconInfo.iconLeft, 'px -', iconInfo.iconTop,
'px;', vAlign].join('');
}
}
|
[
"function",
"(",
"iconInfo",
")",
"{",
"var",
"cfg",
"=",
"this",
".",
"_cfg",
";",
"var",
"vAlign",
"=",
"!",
"cfg",
".",
"verticalAlign",
"?",
"\"\"",
":",
"\"vertical-align: \"",
"+",
"cfg",
".",
"verticalAlign",
";",
"var",
"margins",
"=",
"\"margin: 0 0 0 0 \"",
";",
"if",
"(",
"cfg",
".",
"margins",
"!=",
"null",
"&&",
"cfg",
".",
"margins",
".",
"match",
"(",
"/",
"^(\\d+|x) (\\d+|x) (\\d+|x) (\\d+|x)$",
"/",
")",
")",
"{",
"var",
"margArray",
"=",
"cfg",
".",
"margins",
".",
"split",
"(",
"\" \"",
")",
";",
"margins",
"=",
"[",
"'margin:'",
",",
"margArray",
"[",
"0",
"]",
",",
"'px '",
",",
"margArray",
"[",
"1",
"]",
",",
"'px '",
",",
"margArray",
"[",
"2",
"]",
",",
"'px '",
",",
"margArray",
"[",
"3",
"]",
",",
"'px; '",
"]",
".",
"join",
"(",
"''",
")",
";",
"}",
"else",
"if",
"(",
"iconInfo",
".",
"margins",
"!=",
"null",
")",
"{",
"margins",
"=",
"iconInfo",
".",
"margins",
";",
"}",
"if",
"(",
"cfg",
".",
"sourceImage",
")",
"{",
"return",
"[",
"margins",
",",
"';padding:0;background:url('",
",",
"iconInfo",
".",
"imageURL",
",",
"') no-repeat; width:'",
",",
"iconInfo",
".",
"width",
",",
"'px;height:'",
",",
"iconInfo",
".",
"height",
",",
"'px;'",
",",
"vAlign",
"]",
".",
"join",
"(",
"''",
")",
";",
"}",
"else",
"{",
"return",
"[",
"margins",
",",
"';padding:0;background-position:-'",
",",
"iconInfo",
".",
"iconLeft",
",",
"'px -'",
",",
"iconInfo",
".",
"iconTop",
",",
"'px;'",
",",
"vAlign",
"]",
".",
"join",
"(",
"''",
")",
";",
"}",
"}"
] |
Return the icon style for a given icon skin
@param {Object} iconInfo
@protected
@return {String}
|
[
"Return",
"the",
"icon",
"style",
"for",
"a",
"given",
"icon",
"skin"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/Icon.js#L235-L254
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/Icon.js
|
function (iconInfo) {
var cfg = this._cfg;
var cssClasses = ariaCoreTplClassLoader.addPrintOptions(this._cssClassNames, cfg.printOptions);
if (iconInfo.cssClass) {
cssClasses += " " + iconInfo.cssClass;
}
if (cfg.block) {
cssClasses += " xBlock";
}
return cssClasses;
}
|
javascript
|
function (iconInfo) {
var cfg = this._cfg;
var cssClasses = ariaCoreTplClassLoader.addPrintOptions(this._cssClassNames, cfg.printOptions);
if (iconInfo.cssClass) {
cssClasses += " " + iconInfo.cssClass;
}
if (cfg.block) {
cssClasses += " xBlock";
}
return cssClasses;
}
|
[
"function",
"(",
"iconInfo",
")",
"{",
"var",
"cfg",
"=",
"this",
".",
"_cfg",
";",
"var",
"cssClasses",
"=",
"ariaCoreTplClassLoader",
".",
"addPrintOptions",
"(",
"this",
".",
"_cssClassNames",
",",
"cfg",
".",
"printOptions",
")",
";",
"if",
"(",
"iconInfo",
".",
"cssClass",
")",
"{",
"cssClasses",
"+=",
"\" \"",
"+",
"iconInfo",
".",
"cssClass",
";",
"}",
"if",
"(",
"cfg",
".",
"block",
")",
"{",
"cssClasses",
"+=",
"\" xBlock\"",
";",
"}",
"return",
"cssClasses",
";",
"}"
] |
Return the icon classes for a given icon
@param {Object} iconInfo
@protected
@return {String}
|
[
"Return",
"the",
"icon",
"classes",
"for",
"a",
"given",
"icon"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/Icon.js#L262-L272
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/Icon.js
|
function (domEvent) {
var cfg = this._cfg;
if (cfg) {
var domEvtWrapper;
if (domEvent) {
domEvtWrapper = new aria.templates.DomEventWrapper(domEvent);
}
var returnValue = this.evalCallback(cfg.onclick, domEvtWrapper);
if (domEvtWrapper) {
domEvtWrapper.$dispose();
}
return returnValue;
}
return true;
}
|
javascript
|
function (domEvent) {
var cfg = this._cfg;
if (cfg) {
var domEvtWrapper;
if (domEvent) {
domEvtWrapper = new aria.templates.DomEventWrapper(domEvent);
}
var returnValue = this.evalCallback(cfg.onclick, domEvtWrapper);
if (domEvtWrapper) {
domEvtWrapper.$dispose();
}
return returnValue;
}
return true;
}
|
[
"function",
"(",
"domEvent",
")",
"{",
"var",
"cfg",
"=",
"this",
".",
"_cfg",
";",
"if",
"(",
"cfg",
")",
"{",
"var",
"domEvtWrapper",
";",
"if",
"(",
"domEvent",
")",
"{",
"domEvtWrapper",
"=",
"new",
"aria",
".",
"templates",
".",
"DomEventWrapper",
"(",
"domEvent",
")",
";",
"}",
"var",
"returnValue",
"=",
"this",
".",
"evalCallback",
"(",
"cfg",
".",
"onclick",
",",
"domEvtWrapper",
")",
";",
"if",
"(",
"domEvtWrapper",
")",
"{",
"domEvtWrapper",
".",
"$dispose",
"(",
")",
";",
"}",
"return",
"returnValue",
";",
"}",
"return",
"true",
";",
"}"
] |
The method called when the markup is clicked
@param {aria.DomEvent} evt Event
@protected
|
[
"The",
"method",
"called",
"when",
"the",
"markup",
"is",
"clicked"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/Icon.js#L289-L303
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/utils/css/Effects.js
|
function (htmlElem, properties, cfg) {
var animId;
cfg = cfg || {};
var elem = this._getHTMLElement(htmlElem), animInfo = {
props : []
};
if (elem == null) {
this.$logWarn(this.INVALID_HTML_ELEMENT);
return null;
}
animInfo.duration = cfg.duration ? parseInt(cfg.duration, 10) : this.DEFAULT_DURATION;
animInfo.interval = cfg.interval ? parseInt(cfg.interval, 10) : this.DEFAULT_INTERVAL;
if (cfg.easing != null) {
if (ariaUtilsType.isFunction(cfg.easing)) {
animInfo.easing = cfg.easing;
} else if (ariaUtilsType.isString(cfg.easing)) {
animInfo.easing = this._easing[cfg.easing];
}
}
animInfo.easing = animInfo.easing || this._easing[this.DEFAULT_EASING];
animInfo.queue = (cfg.queue === true) ? this.DEFAULT_QUEUE_KEY : (cfg.queue != null)
? this._getQueueKey(cfg.queue)
: false;
animInfo.element = elem;
animInfo.userProperties = properties;
animInfo.onStartAnimation = cfg.onStartAnimation;
animInfo.onEndAnimation = cfg.onEndAnimation;
animInfo.onEndQueue = cfg.onEndQueue;
animInfo.hide = cfg.hide;
if (animInfo.queue) {
// if it is the first animation of its queue
if (!this.queues[animInfo.queue]) {
this.queues[animInfo.queue] = {
list : [animInfo],
onEndQueue : cfg.onEndQueue
};
this.$callback(cfg.onStartQueue);
animId = this._createAndLaunchAnimation(animInfo);
} else {
animId = this._createAnimationSpot();
this.queues[animInfo.queue].list.push(animInfo);
}
} else {
animId = this._createAndLaunchAnimation(animInfo);
}
animInfo.animId = animId;
this.animations[animId] = animInfo;
return animId;
}
|
javascript
|
function (htmlElem, properties, cfg) {
var animId;
cfg = cfg || {};
var elem = this._getHTMLElement(htmlElem), animInfo = {
props : []
};
if (elem == null) {
this.$logWarn(this.INVALID_HTML_ELEMENT);
return null;
}
animInfo.duration = cfg.duration ? parseInt(cfg.duration, 10) : this.DEFAULT_DURATION;
animInfo.interval = cfg.interval ? parseInt(cfg.interval, 10) : this.DEFAULT_INTERVAL;
if (cfg.easing != null) {
if (ariaUtilsType.isFunction(cfg.easing)) {
animInfo.easing = cfg.easing;
} else if (ariaUtilsType.isString(cfg.easing)) {
animInfo.easing = this._easing[cfg.easing];
}
}
animInfo.easing = animInfo.easing || this._easing[this.DEFAULT_EASING];
animInfo.queue = (cfg.queue === true) ? this.DEFAULT_QUEUE_KEY : (cfg.queue != null)
? this._getQueueKey(cfg.queue)
: false;
animInfo.element = elem;
animInfo.userProperties = properties;
animInfo.onStartAnimation = cfg.onStartAnimation;
animInfo.onEndAnimation = cfg.onEndAnimation;
animInfo.onEndQueue = cfg.onEndQueue;
animInfo.hide = cfg.hide;
if (animInfo.queue) {
// if it is the first animation of its queue
if (!this.queues[animInfo.queue]) {
this.queues[animInfo.queue] = {
list : [animInfo],
onEndQueue : cfg.onEndQueue
};
this.$callback(cfg.onStartQueue);
animId = this._createAndLaunchAnimation(animInfo);
} else {
animId = this._createAnimationSpot();
this.queues[animInfo.queue].list.push(animInfo);
}
} else {
animId = this._createAndLaunchAnimation(animInfo);
}
animInfo.animId = animId;
this.animations[animId] = animInfo;
return animId;
}
|
[
"function",
"(",
"htmlElem",
",",
"properties",
",",
"cfg",
")",
"{",
"var",
"animId",
";",
"cfg",
"=",
"cfg",
"||",
"{",
"}",
";",
"var",
"elem",
"=",
"this",
".",
"_getHTMLElement",
"(",
"htmlElem",
")",
",",
"animInfo",
"=",
"{",
"props",
":",
"[",
"]",
"}",
";",
"if",
"(",
"elem",
"==",
"null",
")",
"{",
"this",
".",
"$logWarn",
"(",
"this",
".",
"INVALID_HTML_ELEMENT",
")",
";",
"return",
"null",
";",
"}",
"animInfo",
".",
"duration",
"=",
"cfg",
".",
"duration",
"?",
"parseInt",
"(",
"cfg",
".",
"duration",
",",
"10",
")",
":",
"this",
".",
"DEFAULT_DURATION",
";",
"animInfo",
".",
"interval",
"=",
"cfg",
".",
"interval",
"?",
"parseInt",
"(",
"cfg",
".",
"interval",
",",
"10",
")",
":",
"this",
".",
"DEFAULT_INTERVAL",
";",
"if",
"(",
"cfg",
".",
"easing",
"!=",
"null",
")",
"{",
"if",
"(",
"ariaUtilsType",
".",
"isFunction",
"(",
"cfg",
".",
"easing",
")",
")",
"{",
"animInfo",
".",
"easing",
"=",
"cfg",
".",
"easing",
";",
"}",
"else",
"if",
"(",
"ariaUtilsType",
".",
"isString",
"(",
"cfg",
".",
"easing",
")",
")",
"{",
"animInfo",
".",
"easing",
"=",
"this",
".",
"_easing",
"[",
"cfg",
".",
"easing",
"]",
";",
"}",
"}",
"animInfo",
".",
"easing",
"=",
"animInfo",
".",
"easing",
"||",
"this",
".",
"_easing",
"[",
"this",
".",
"DEFAULT_EASING",
"]",
";",
"animInfo",
".",
"queue",
"=",
"(",
"cfg",
".",
"queue",
"===",
"true",
")",
"?",
"this",
".",
"DEFAULT_QUEUE_KEY",
":",
"(",
"cfg",
".",
"queue",
"!=",
"null",
")",
"?",
"this",
".",
"_getQueueKey",
"(",
"cfg",
".",
"queue",
")",
":",
"false",
";",
"animInfo",
".",
"element",
"=",
"elem",
";",
"animInfo",
".",
"userProperties",
"=",
"properties",
";",
"animInfo",
".",
"onStartAnimation",
"=",
"cfg",
".",
"onStartAnimation",
";",
"animInfo",
".",
"onEndAnimation",
"=",
"cfg",
".",
"onEndAnimation",
";",
"animInfo",
".",
"onEndQueue",
"=",
"cfg",
".",
"onEndQueue",
";",
"animInfo",
".",
"hide",
"=",
"cfg",
".",
"hide",
";",
"if",
"(",
"animInfo",
".",
"queue",
")",
"{",
"if",
"(",
"!",
"this",
".",
"queues",
"[",
"animInfo",
".",
"queue",
"]",
")",
"{",
"this",
".",
"queues",
"[",
"animInfo",
".",
"queue",
"]",
"=",
"{",
"list",
":",
"[",
"animInfo",
"]",
",",
"onEndQueue",
":",
"cfg",
".",
"onEndQueue",
"}",
";",
"this",
".",
"$callback",
"(",
"cfg",
".",
"onStartQueue",
")",
";",
"animId",
"=",
"this",
".",
"_createAndLaunchAnimation",
"(",
"animInfo",
")",
";",
"}",
"else",
"{",
"animId",
"=",
"this",
".",
"_createAnimationSpot",
"(",
")",
";",
"this",
".",
"queues",
"[",
"animInfo",
".",
"queue",
"]",
".",
"list",
".",
"push",
"(",
"animInfo",
")",
";",
"}",
"}",
"else",
"{",
"animId",
"=",
"this",
".",
"_createAndLaunchAnimation",
"(",
"animInfo",
")",
";",
"}",
"animInfo",
".",
"animId",
"=",
"animId",
";",
"this",
".",
"animations",
"[",
"animId",
"]",
"=",
"animInfo",
";",
"return",
"animId",
";",
"}"
] |
Starts the animation
@param {HTMLElement|String} element to be animated (or its id)
@param {Object} CSS properties
@param {Object} cfg animation configuration
@return {String} animation ID
|
[
"Starts",
"the",
"animation"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/css/Effects.js#L136-L186
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/utils/css/Effects.js
|
function (queueId) {
var id = queueId;
if (queueId == null) {
id = this.DEFAULT_QUEUE_KEY;
}
var queue = this.queues[id];
if (queue && queue.list.length > 0) {
var curAnimInfo = queue.list.shift();
for (var i = 1, l = queue.list.length; i < l; i++) {
var animInfo = queue.list[i];
delete this.animations[animInfo.animId];
}
this.skipAnimation(curAnimInfo.animId);
delete this.queues[id];
return true;
}
return false;
}
|
javascript
|
function (queueId) {
var id = queueId;
if (queueId == null) {
id = this.DEFAULT_QUEUE_KEY;
}
var queue = this.queues[id];
if (queue && queue.list.length > 0) {
var curAnimInfo = queue.list.shift();
for (var i = 1, l = queue.list.length; i < l; i++) {
var animInfo = queue.list[i];
delete this.animations[animInfo.animId];
}
this.skipAnimation(curAnimInfo.animId);
delete this.queues[id];
return true;
}
return false;
}
|
[
"function",
"(",
"queueId",
")",
"{",
"var",
"id",
"=",
"queueId",
";",
"if",
"(",
"queueId",
"==",
"null",
")",
"{",
"id",
"=",
"this",
".",
"DEFAULT_QUEUE_KEY",
";",
"}",
"var",
"queue",
"=",
"this",
".",
"queues",
"[",
"id",
"]",
";",
"if",
"(",
"queue",
"&&",
"queue",
".",
"list",
".",
"length",
">",
"0",
")",
"{",
"var",
"curAnimInfo",
"=",
"queue",
".",
"list",
".",
"shift",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"1",
",",
"l",
"=",
"queue",
".",
"list",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"var",
"animInfo",
"=",
"queue",
".",
"list",
"[",
"i",
"]",
";",
"delete",
"this",
".",
"animations",
"[",
"animInfo",
".",
"animId",
"]",
";",
"}",
"this",
".",
"skipAnimation",
"(",
"curAnimInfo",
".",
"animId",
")",
";",
"delete",
"this",
".",
"queues",
"[",
"id",
"]",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Stops the execution of a queue and delete all its animations
@param {String} queue identifier
@return {Boolean} true if the related queue exists and is not empty, otherwise false
|
[
"Stops",
"the",
"execution",
"of",
"a",
"queue",
"and",
"delete",
"all",
"its",
"animations"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/css/Effects.js#L215-L232
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/utils/css/Effects.js
|
function (idQueue) {
var id = idQueue;
if (idQueue == null) {
id = this.DEFAULT_QUEUE_KEY;
}
var queue = this.queues[id];
if (queue && queue.list.length > 0 && !queue.list[0].isRunning) {
// if first animation in queue has been paused (and not skipped afterwards)
if (queue.list[0].pauseTime != null) {
this.resumeAnimation(queue.list[0].animId);
} else { // if the paused animation has been skipped
this._launchAnimation(queue.list[0], queue.list[0].animId);
}
return true;
}
return false;
}
|
javascript
|
function (idQueue) {
var id = idQueue;
if (idQueue == null) {
id = this.DEFAULT_QUEUE_KEY;
}
var queue = this.queues[id];
if (queue && queue.list.length > 0 && !queue.list[0].isRunning) {
// if first animation in queue has been paused (and not skipped afterwards)
if (queue.list[0].pauseTime != null) {
this.resumeAnimation(queue.list[0].animId);
} else { // if the paused animation has been skipped
this._launchAnimation(queue.list[0], queue.list[0].animId);
}
return true;
}
return false;
}
|
[
"function",
"(",
"idQueue",
")",
"{",
"var",
"id",
"=",
"idQueue",
";",
"if",
"(",
"idQueue",
"==",
"null",
")",
"{",
"id",
"=",
"this",
".",
"DEFAULT_QUEUE_KEY",
";",
"}",
"var",
"queue",
"=",
"this",
".",
"queues",
"[",
"id",
"]",
";",
"if",
"(",
"queue",
"&&",
"queue",
".",
"list",
".",
"length",
">",
"0",
"&&",
"!",
"queue",
".",
"list",
"[",
"0",
"]",
".",
"isRunning",
")",
"{",
"if",
"(",
"queue",
".",
"list",
"[",
"0",
"]",
".",
"pauseTime",
"!=",
"null",
")",
"{",
"this",
".",
"resumeAnimation",
"(",
"queue",
".",
"list",
"[",
"0",
"]",
".",
"animId",
")",
";",
"}",
"else",
"{",
"this",
".",
"_launchAnimation",
"(",
"queue",
".",
"list",
"[",
"0",
"]",
",",
"queue",
".",
"list",
"[",
"0",
"]",
".",
"animId",
")",
";",
"}",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Resumes a paused queue
@param {String} queue identifier
@return {Boolean} true if the related queue exists and is not empty, otherwise false
|
[
"Resumes",
"a",
"paused",
"queue"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/css/Effects.js#L296-L312
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/utils/css/Units.js
|
function (valueWithUnit, elem, property) {
var unit = this.getUnit(valueWithUnit, property);
var value = parseFloat(valueWithUnit, 10);
return this.__convertToPixels[unit].call(this, value, elem, property);
}
|
javascript
|
function (valueWithUnit, elem, property) {
var unit = this.getUnit(valueWithUnit, property);
var value = parseFloat(valueWithUnit, 10);
return this.__convertToPixels[unit].call(this, value, elem, property);
}
|
[
"function",
"(",
"valueWithUnit",
",",
"elem",
",",
"property",
")",
"{",
"var",
"unit",
"=",
"this",
".",
"getUnit",
"(",
"valueWithUnit",
",",
"property",
")",
";",
"var",
"value",
"=",
"parseFloat",
"(",
"valueWithUnit",
",",
"10",
")",
";",
"return",
"this",
".",
"__convertToPixels",
"[",
"unit",
"]",
".",
"call",
"(",
"this",
",",
"value",
",",
"elem",
",",
"property",
")",
";",
"}"
] |
Converts the value of a given CSS property of a given HTML element from any CSS units into pixels
@param {String} valueWithUnit valid CSS value with unit e.g. "12pt", "1em", "10px"
@param {HTMLElement} elem Needed if <code>valueWithUnit</code> is in "em" or "%", can be null
otherwise.
@param {String} property camelCased CSS property name
@return {Number} value in pixels
|
[
"Converts",
"the",
"value",
"of",
"a",
"given",
"CSS",
"property",
"of",
"a",
"given",
"HTML",
"element",
"from",
"any",
"CSS",
"units",
"into",
"pixels"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/css/Units.js#L194-L198
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/utils/css/Units.js
|
function (newUnit, valueInPixels, elem, property) {
return this.__convertFromPixels[newUnit].call(this, valueInPixels, elem, property);
}
|
javascript
|
function (newUnit, valueInPixels, elem, property) {
return this.__convertFromPixels[newUnit].call(this, valueInPixels, elem, property);
}
|
[
"function",
"(",
"newUnit",
",",
"valueInPixels",
",",
"elem",
",",
"property",
")",
"{",
"return",
"this",
".",
"__convertFromPixels",
"[",
"newUnit",
"]",
".",
"call",
"(",
"this",
",",
"valueInPixels",
",",
"elem",
",",
"property",
")",
";",
"}"
] |
Converts the value of a given CSS property of a given HTML element from pixels into chosen CSS unit.
@param {String} newUnit e.g. "pt", "em"
@param {Number} valueInPixels
@param {HTMLElement} elem Needed if <code>newUnit</code> is in "em" or "%", can be null otherwise.
@param {String} property camelCased CSS property name
@return {Number} value in units provided via <code>newUnit</code>
|
[
"Converts",
"the",
"value",
"of",
"a",
"given",
"CSS",
"property",
"of",
"a",
"given",
"HTML",
"element",
"from",
"pixels",
"into",
"chosen",
"CSS",
"unit",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/css/Units.js#L208-L210
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/utils/css/Units.js
|
function (element, property) {
if (this.isIE8orLess) {
return element.currentStyle[property] || element.style[property];
} else {
return Aria.$window.getComputedStyle(element, "")[property] || element.style[property];
}
}
|
javascript
|
function (element, property) {
if (this.isIE8orLess) {
return element.currentStyle[property] || element.style[property];
} else {
return Aria.$window.getComputedStyle(element, "")[property] || element.style[property];
}
}
|
[
"function",
"(",
"element",
",",
"property",
")",
"{",
"if",
"(",
"this",
".",
"isIE8orLess",
")",
"{",
"return",
"element",
".",
"currentStyle",
"[",
"property",
"]",
"||",
"element",
".",
"style",
"[",
"property",
"]",
";",
"}",
"else",
"{",
"return",
"Aria",
".",
"$window",
".",
"getComputedStyle",
"(",
"element",
",",
"\"\"",
")",
"[",
"property",
"]",
"||",
"element",
".",
"style",
"[",
"property",
"]",
";",
"}",
"}"
] |
Function created to not have circular dependency on aria.utils.Dom. To be used to retrieve the style for
properties which do not need any special treatment.
|
[
"Function",
"created",
"to",
"not",
"have",
"circular",
"dependency",
"on",
"aria",
".",
"utils",
".",
"Dom",
".",
"To",
"be",
"used",
"to",
"retrieve",
"the",
"style",
"for",
"properties",
"which",
"do",
"not",
"need",
"any",
"special",
"treatment",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/css/Units.js#L323-L329
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/embed/Placeholder.js
|
function (out) {
var typeUtil = ariaUtilsType, placeholderManager = ariaEmbedPlaceholderManager;
var placeholderPath = this._placeholderPath;
var contents = placeholderManager.getContent(placeholderPath);
for (var i = 0, ii = contents.length; i < ii; i++) {
var content = contents[i];
if (typeUtil.isString(content)) {
out.write(content);
} else {
// Assume json here (aria.html.beans.TemplateCfg)
var template = new ariaHtmlTemplate(content, this._context, this._lineNumber);
template.subTplCtxt.placeholderPath = placeholderPath;
out.registerBehavior(template);
template.writeMarkup(out);
}
}
}
|
javascript
|
function (out) {
var typeUtil = ariaUtilsType, placeholderManager = ariaEmbedPlaceholderManager;
var placeholderPath = this._placeholderPath;
var contents = placeholderManager.getContent(placeholderPath);
for (var i = 0, ii = contents.length; i < ii; i++) {
var content = contents[i];
if (typeUtil.isString(content)) {
out.write(content);
} else {
// Assume json here (aria.html.beans.TemplateCfg)
var template = new ariaHtmlTemplate(content, this._context, this._lineNumber);
template.subTplCtxt.placeholderPath = placeholderPath;
out.registerBehavior(template);
template.writeMarkup(out);
}
}
}
|
[
"function",
"(",
"out",
")",
"{",
"var",
"typeUtil",
"=",
"ariaUtilsType",
",",
"placeholderManager",
"=",
"ariaEmbedPlaceholderManager",
";",
"var",
"placeholderPath",
"=",
"this",
".",
"_placeholderPath",
";",
"var",
"contents",
"=",
"placeholderManager",
".",
"getContent",
"(",
"placeholderPath",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"ii",
"=",
"contents",
".",
"length",
";",
"i",
"<",
"ii",
";",
"i",
"++",
")",
"{",
"var",
"content",
"=",
"contents",
"[",
"i",
"]",
";",
"if",
"(",
"typeUtil",
".",
"isString",
"(",
"content",
")",
")",
"{",
"out",
".",
"write",
"(",
"content",
")",
";",
"}",
"else",
"{",
"var",
"template",
"=",
"new",
"ariaHtmlTemplate",
"(",
"content",
",",
"this",
".",
"_context",
",",
"this",
".",
"_lineNumber",
")",
";",
"template",
".",
"subTplCtxt",
".",
"placeholderPath",
"=",
"placeholderPath",
";",
"out",
".",
"registerBehavior",
"(",
"template",
")",
";",
"template",
".",
"writeMarkup",
"(",
"out",
")",
";",
"}",
"}",
"}"
] |
Write the content of the placeholder
@param {aria.templates.MarkupWriter} out
@private
|
[
"Write",
"the",
"content",
"of",
"the",
"placeholder"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/embed/Placeholder.js#L114-L130
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/embed/Placeholder.js
|
function (event) {
var paths = event.placeholderPaths;
if (ariaUtilsArray.contains(paths, this._placeholderPath)) {
var newSection = this._context.getRefreshedSection({
section : this._sectionId,
writerCallback : {
fn : this._writePlaceholderContent,
scope : this
}
});
this._context.insertSection(newSection);
}
}
|
javascript
|
function (event) {
var paths = event.placeholderPaths;
if (ariaUtilsArray.contains(paths, this._placeholderPath)) {
var newSection = this._context.getRefreshedSection({
section : this._sectionId,
writerCallback : {
fn : this._writePlaceholderContent,
scope : this
}
});
this._context.insertSection(newSection);
}
}
|
[
"function",
"(",
"event",
")",
"{",
"var",
"paths",
"=",
"event",
".",
"placeholderPaths",
";",
"if",
"(",
"ariaUtilsArray",
".",
"contains",
"(",
"paths",
",",
"this",
".",
"_placeholderPath",
")",
")",
"{",
"var",
"newSection",
"=",
"this",
".",
"_context",
".",
"getRefreshedSection",
"(",
"{",
"section",
":",
"this",
".",
"_sectionId",
",",
"writerCallback",
":",
"{",
"fn",
":",
"this",
".",
"_writePlaceholderContent",
",",
"scope",
":",
"this",
"}",
"}",
")",
";",
"this",
".",
"_context",
".",
"insertSection",
"(",
"newSection",
")",
";",
"}",
"}"
] |
Method that is called when the Placeholder Manager raises the contentChange event
@param {Object} event Contains the placeholderpaths whose content has changed
@private
|
[
"Method",
"that",
"is",
"called",
"when",
"the",
"Placeholder",
"Manager",
"raises",
"the",
"contentChange",
"event"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/embed/Placeholder.js#L137-L149
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/embed/Placeholder.js
|
function () {
var placeholderPath = "";
var currentContext = this._context;
while (currentContext) {
if (currentContext.placeholderPath) {
placeholderPath = currentContext.placeholderPath + ".";
break;
}
currentContext = currentContext.parent;
}
return placeholderPath + this._cfg.name;
}
|
javascript
|
function () {
var placeholderPath = "";
var currentContext = this._context;
while (currentContext) {
if (currentContext.placeholderPath) {
placeholderPath = currentContext.placeholderPath + ".";
break;
}
currentContext = currentContext.parent;
}
return placeholderPath + this._cfg.name;
}
|
[
"function",
"(",
")",
"{",
"var",
"placeholderPath",
"=",
"\"\"",
";",
"var",
"currentContext",
"=",
"this",
".",
"_context",
";",
"while",
"(",
"currentContext",
")",
"{",
"if",
"(",
"currentContext",
".",
"placeholderPath",
")",
"{",
"placeholderPath",
"=",
"currentContext",
".",
"placeholderPath",
"+",
"\".\"",
";",
"break",
";",
"}",
"currentContext",
"=",
"currentContext",
".",
"parent",
";",
"}",
"return",
"placeholderPath",
"+",
"this",
".",
"_cfg",
".",
"name",
";",
"}"
] |
Computes the path of the placeholder by combining context information with the placeholder name
@return {String} path of the placeholder
@private
|
[
"Computes",
"the",
"path",
"of",
"the",
"placeholder",
"by",
"combining",
"context",
"information",
"with",
"the",
"placeholder",
"name"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/embed/Placeholder.js#L156-L167
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/core/IOFiltersMgr.js
|
function (search) {
findFilterRes = null;
findFilterSearch = search;
if (typeUtils.isString(search)) {
return findByClasspath;
} else if (typeUtils.isInstanceOf(search, "aria.core.IOFilter")) {
return findByInstance;
} else if (typeUtils.isObject(search)) {
return findByClasspathAndInitArgs;
} else {
return null;
}
}
|
javascript
|
function (search) {
findFilterRes = null;
findFilterSearch = search;
if (typeUtils.isString(search)) {
return findByClasspath;
} else if (typeUtils.isInstanceOf(search, "aria.core.IOFilter")) {
return findByInstance;
} else if (typeUtils.isObject(search)) {
return findByClasspathAndInitArgs;
} else {
return null;
}
}
|
[
"function",
"(",
"search",
")",
"{",
"findFilterRes",
"=",
"null",
";",
"findFilterSearch",
"=",
"search",
";",
"if",
"(",
"typeUtils",
".",
"isString",
"(",
"search",
")",
")",
"{",
"return",
"findByClasspath",
";",
"}",
"else",
"if",
"(",
"typeUtils",
".",
"isInstanceOf",
"(",
"search",
",",
"\"aria.core.IOFilter\"",
")",
")",
"{",
"return",
"findByInstance",
";",
"}",
"else",
"if",
"(",
"typeUtils",
".",
"isObject",
"(",
"search",
")",
")",
"{",
"return",
"findByClasspathAndInitArgs",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Initialize the search and return one of the findByClasspath, findByInstance or findByClasspathAndInitArgs
functions depending on the type of the search parameter.
@param {MultiTypes} search Filter to be found. Can be of any type accepted for the parameter of isFilterPresent.
@return {Function} either null (if the search parameter has an unexpected type), or a reference to one of the
findByClasspath, findByInstance or findByClasspathAndInitArgs functions.
@private
|
[
"Initialize",
"the",
"search",
"and",
"return",
"one",
"of",
"the",
"findByClasspath",
"findByInstance",
"or",
"findByClasspathAndInitArgs",
"functions",
"depending",
"on",
"the",
"type",
"of",
"the",
"search",
"parameter",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/IOFiltersMgr.js#L89-L101
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/core/IOFiltersMgr.js
|
function (newFilter) {
var filterInfo = {};
if (typeUtils.isString(newFilter)) {
filterInfo.filterClasspath = newFilter;
filterInfo.initArgs = null;
this._filtersToBeLoaded++;
} else if (typeUtils.isInstanceOf(newFilter, "aria.core.IOFilter")) {
if (this.isFilterPresent(newFilter)) {
this.$logError(this.FILTER_INSTANCE_ALREADY_PRESENT);
return false;
}
filterInfo.filterClasspath = newFilter.$classpath;
filterInfo.obj = newFilter;
} else if (typeUtils.isObject(newFilter)) {
filterInfo.filterClasspath = newFilter.classpath;
filterInfo.initArgs = newFilter.initArgs;
this._filtersToBeLoaded++;
} else {
this.$logError(this.INVALID_PARAMETER_FOR_ADDFILTER);
return false;
}
if (!this._filters) {
this._filters = [];
}
this._filters[this._filters.length] = filterInfo;
return true;
}
|
javascript
|
function (newFilter) {
var filterInfo = {};
if (typeUtils.isString(newFilter)) {
filterInfo.filterClasspath = newFilter;
filterInfo.initArgs = null;
this._filtersToBeLoaded++;
} else if (typeUtils.isInstanceOf(newFilter, "aria.core.IOFilter")) {
if (this.isFilterPresent(newFilter)) {
this.$logError(this.FILTER_INSTANCE_ALREADY_PRESENT);
return false;
}
filterInfo.filterClasspath = newFilter.$classpath;
filterInfo.obj = newFilter;
} else if (typeUtils.isObject(newFilter)) {
filterInfo.filterClasspath = newFilter.classpath;
filterInfo.initArgs = newFilter.initArgs;
this._filtersToBeLoaded++;
} else {
this.$logError(this.INVALID_PARAMETER_FOR_ADDFILTER);
return false;
}
if (!this._filters) {
this._filters = [];
}
this._filters[this._filters.length] = filterInfo;
return true;
}
|
[
"function",
"(",
"newFilter",
")",
"{",
"var",
"filterInfo",
"=",
"{",
"}",
";",
"if",
"(",
"typeUtils",
".",
"isString",
"(",
"newFilter",
")",
")",
"{",
"filterInfo",
".",
"filterClasspath",
"=",
"newFilter",
";",
"filterInfo",
".",
"initArgs",
"=",
"null",
";",
"this",
".",
"_filtersToBeLoaded",
"++",
";",
"}",
"else",
"if",
"(",
"typeUtils",
".",
"isInstanceOf",
"(",
"newFilter",
",",
"\"aria.core.IOFilter\"",
")",
")",
"{",
"if",
"(",
"this",
".",
"isFilterPresent",
"(",
"newFilter",
")",
")",
"{",
"this",
".",
"$logError",
"(",
"this",
".",
"FILTER_INSTANCE_ALREADY_PRESENT",
")",
";",
"return",
"false",
";",
"}",
"filterInfo",
".",
"filterClasspath",
"=",
"newFilter",
".",
"$classpath",
";",
"filterInfo",
".",
"obj",
"=",
"newFilter",
";",
"}",
"else",
"if",
"(",
"typeUtils",
".",
"isObject",
"(",
"newFilter",
")",
")",
"{",
"filterInfo",
".",
"filterClasspath",
"=",
"newFilter",
".",
"classpath",
";",
"filterInfo",
".",
"initArgs",
"=",
"newFilter",
".",
"initArgs",
";",
"this",
".",
"_filtersToBeLoaded",
"++",
";",
"}",
"else",
"{",
"this",
".",
"$logError",
"(",
"this",
".",
"INVALID_PARAMETER_FOR_ADDFILTER",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"this",
".",
"_filters",
")",
"{",
"this",
".",
"_filters",
"=",
"[",
"]",
";",
"}",
"this",
".",
"_filters",
"[",
"this",
".",
"_filters",
".",
"length",
"]",
"=",
"filterInfo",
";",
"return",
"true",
";",
"}"
] |
Add an IO filter.
@param {MultiTypes} newFilter It can be one of the following possibilities:
<ul>
<li>An instance of a filter class.</li>
<li>An object containing two properties: classpath and initArgs. In this case, the filter class with the
given classpath will be instantiated when needed. Its constructor will be called with the given initArgs
parameter.</li>
<li>The classpath of a filter class (equivalent to the previous case, but with a null initArgs
parameter).</li>
</ul>
Note that a filter class must extend aria.core.IOFilter. Two different instances of the same filter class
can be added at the same time. However, the same instance cannot be added twice (in that case, an error
is logged and this method returns false).
@return {Boolean} Return true if the filter was successfully added and false if there was an error (in
this case, an error is logged).
|
[
"Add",
"an",
"IO",
"filter",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/IOFiltersMgr.js#L169-L195
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/core/IOFiltersMgr.js
|
function (filterDef) {
var filters = this._filters;
// stop here if there are no filters
if (!filters) {
return false;
}
var isWrongFilter = getFindFilterFunction(filterDef);
if (isWrongFilter == null) {
this.$logError(this.INVALID_PARAMETER_FOR_ISFILTERPRESENT);
clean();
return false;
}
for (var i = 0, l = filters.length; i < l; i++) {
if (!isWrongFilter(filters[i])) {
clean();
return true;
}
}
clean();
return false;
}
|
javascript
|
function (filterDef) {
var filters = this._filters;
// stop here if there are no filters
if (!filters) {
return false;
}
var isWrongFilter = getFindFilterFunction(filterDef);
if (isWrongFilter == null) {
this.$logError(this.INVALID_PARAMETER_FOR_ISFILTERPRESENT);
clean();
return false;
}
for (var i = 0, l = filters.length; i < l; i++) {
if (!isWrongFilter(filters[i])) {
clean();
return true;
}
}
clean();
return false;
}
|
[
"function",
"(",
"filterDef",
")",
"{",
"var",
"filters",
"=",
"this",
".",
"_filters",
";",
"if",
"(",
"!",
"filters",
")",
"{",
"return",
"false",
";",
"}",
"var",
"isWrongFilter",
"=",
"getFindFilterFunction",
"(",
"filterDef",
")",
";",
"if",
"(",
"isWrongFilter",
"==",
"null",
")",
"{",
"this",
".",
"$logError",
"(",
"this",
".",
"INVALID_PARAMETER_FOR_ISFILTERPRESENT",
")",
";",
"clean",
"(",
")",
";",
"return",
"false",
";",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"filters",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"isWrongFilter",
"(",
"filters",
"[",
"i",
"]",
")",
")",
"{",
"clean",
"(",
")",
";",
"return",
"true",
";",
"}",
"}",
"clean",
"(",
")",
";",
"return",
"false",
";",
"}"
] |
Find if a filter is present in the list of filters.
@param {MultiTypes} filter It can be one of the following possibilities:
<ul>
<li>An instance of a filter class.</li>
<li>An object containing two properties: classpath and initArgs.</li>
<li>The classpath of a filter class.</li>
</ul>
@return {Boolean} return true if the filter was found, false if no filter matching the conditions was
found.
|
[
"Find",
"if",
"a",
"filter",
"is",
"present",
"in",
"the",
"list",
"of",
"filters",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/IOFiltersMgr.js#L208-L228
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/core/IOFiltersMgr.js
|
function (oldFilter) {
var filters = this._filters;
// stop here if there are no filters
if (!filters) {
return false;
}
var selectionCallback = getFindFilterFunction(oldFilter);
if (selectionCallback == null) {
this.$logError(this.INVALID_PARAMETER_FOR_REMOVEFILTER);
clean();
return false;
}
var newFiltersArray = arrayUtils.filter(filters, selectionCallback, this);
clean();
var filterToRemove = findFilterRes;
if (filterToRemove) {
if (filterToRemove.obj) {
// already loaded, dispose it
filterToRemove.obj.$dispose();
filterToRemove.obj = null;
} else {
// not yet loaded, prevent it to be loaded
this._filtersToBeLoaded--;
}
filterToRemove.filterClasspath = null;
filterToRemove.initArgs = null;
if (newFiltersArray.length === 0) {
this._filters = null;
} else {
this._filters = newFiltersArray;
}
return true;
}
return false;
}
|
javascript
|
function (oldFilter) {
var filters = this._filters;
// stop here if there are no filters
if (!filters) {
return false;
}
var selectionCallback = getFindFilterFunction(oldFilter);
if (selectionCallback == null) {
this.$logError(this.INVALID_PARAMETER_FOR_REMOVEFILTER);
clean();
return false;
}
var newFiltersArray = arrayUtils.filter(filters, selectionCallback, this);
clean();
var filterToRemove = findFilterRes;
if (filterToRemove) {
if (filterToRemove.obj) {
// already loaded, dispose it
filterToRemove.obj.$dispose();
filterToRemove.obj = null;
} else {
// not yet loaded, prevent it to be loaded
this._filtersToBeLoaded--;
}
filterToRemove.filterClasspath = null;
filterToRemove.initArgs = null;
if (newFiltersArray.length === 0) {
this._filters = null;
} else {
this._filters = newFiltersArray;
}
return true;
}
return false;
}
|
[
"function",
"(",
"oldFilter",
")",
"{",
"var",
"filters",
"=",
"this",
".",
"_filters",
";",
"if",
"(",
"!",
"filters",
")",
"{",
"return",
"false",
";",
"}",
"var",
"selectionCallback",
"=",
"getFindFilterFunction",
"(",
"oldFilter",
")",
";",
"if",
"(",
"selectionCallback",
"==",
"null",
")",
"{",
"this",
".",
"$logError",
"(",
"this",
".",
"INVALID_PARAMETER_FOR_REMOVEFILTER",
")",
";",
"clean",
"(",
")",
";",
"return",
"false",
";",
"}",
"var",
"newFiltersArray",
"=",
"arrayUtils",
".",
"filter",
"(",
"filters",
",",
"selectionCallback",
",",
"this",
")",
";",
"clean",
"(",
")",
";",
"var",
"filterToRemove",
"=",
"findFilterRes",
";",
"if",
"(",
"filterToRemove",
")",
"{",
"if",
"(",
"filterToRemove",
".",
"obj",
")",
"{",
"filterToRemove",
".",
"obj",
".",
"$dispose",
"(",
")",
";",
"filterToRemove",
".",
"obj",
"=",
"null",
";",
"}",
"else",
"{",
"this",
".",
"_filtersToBeLoaded",
"--",
";",
"}",
"filterToRemove",
".",
"filterClasspath",
"=",
"null",
";",
"filterToRemove",
".",
"initArgs",
"=",
"null",
";",
"if",
"(",
"newFiltersArray",
".",
"length",
"===",
"0",
")",
"{",
"this",
".",
"_filters",
"=",
"null",
";",
"}",
"else",
"{",
"this",
".",
"_filters",
"=",
"newFiltersArray",
";",
"}",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Remove a filter added with addFilter, and dispose it.
@param {MultiTypes} oldFilter It can be one of the following possibilities:
<ul>
<li>An instance of a filter class.</li>
<li>An object containing two properties: classpath and initArgs.</li>
<li>The classpath of a filter class.</li>
</ul>
@return {Boolean} return true if a filter was removed, false if no filter matching the conditions was
found.
|
[
"Remove",
"a",
"filter",
"added",
"with",
"addFilter",
"and",
"dispose",
"it",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/IOFiltersMgr.js#L241-L275
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/core/IOFiltersMgr.js
|
function (isResponse, request, cb) {
if (!this._filters) {
this.$callback(cb);
return;
}
var args = {
isResponse : isResponse,
request : request,
cb : cb,
filters : this._filters,
nbFilters : this._filters.length
// store the number of filters so that we do not call filters which were added after the call
// to _callFilters
};
if (this._filtersToBeLoaded > 0
&& (request.sender == null || request.sender.classpath != "aria.core.FileLoader")) {
this._loadMissingFilters({
fn : this._continueCallingFilters,
args : args,
scope : this
});
} else {
this._continueCallingFilters(null, args);
}
}
|
javascript
|
function (isResponse, request, cb) {
if (!this._filters) {
this.$callback(cb);
return;
}
var args = {
isResponse : isResponse,
request : request,
cb : cb,
filters : this._filters,
nbFilters : this._filters.length
// store the number of filters so that we do not call filters which were added after the call
// to _callFilters
};
if (this._filtersToBeLoaded > 0
&& (request.sender == null || request.sender.classpath != "aria.core.FileLoader")) {
this._loadMissingFilters({
fn : this._continueCallingFilters,
args : args,
scope : this
});
} else {
this._continueCallingFilters(null, args);
}
}
|
[
"function",
"(",
"isResponse",
",",
"request",
",",
"cb",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_filters",
")",
"{",
"this",
".",
"$callback",
"(",
"cb",
")",
";",
"return",
";",
"}",
"var",
"args",
"=",
"{",
"isResponse",
":",
"isResponse",
",",
"request",
":",
"request",
",",
"cb",
":",
"cb",
",",
"filters",
":",
"this",
".",
"_filters",
",",
"nbFilters",
":",
"this",
".",
"_filters",
".",
"length",
"}",
";",
"if",
"(",
"this",
".",
"_filtersToBeLoaded",
">",
"0",
"&&",
"(",
"request",
".",
"sender",
"==",
"null",
"||",
"request",
".",
"sender",
".",
"classpath",
"!=",
"\"aria.core.FileLoader\"",
")",
")",
"{",
"this",
".",
"_loadMissingFilters",
"(",
"{",
"fn",
":",
"this",
".",
"_continueCallingFilters",
",",
"args",
":",
"args",
",",
"scope",
":",
"this",
"}",
")",
";",
"}",
"else",
"{",
"this",
".",
"_continueCallingFilters",
"(",
"null",
",",
"args",
")",
";",
"}",
"}"
] |
If there are filters to be loaded, load them, then call all the filters.
@param {Boolean} isResponse
@param {aria.core.CfgBeans:IOAsyncRequestCfg} req request object
@param {aria.core.CfgBeans:Callback} cb callback
@private
|
[
"If",
"there",
"are",
"filters",
"to",
"be",
"loaded",
"load",
"them",
"then",
"call",
"all",
"the",
"filters",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/IOFiltersMgr.js#L304-L328
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/core/IOFiltersMgr.js
|
function (unused, args) {
var filters = args.filters;
var request = args.request;
var curFilter;
// initialize the delay
request.delay = 0;
if (args.isResponse) {
for (var i = args.nbFilters - 1; i >= 0; i--) {
curFilter = filters[i].obj;
if (curFilter) {
curFilter.__onResponse(request);
}
}
} else {
for (var i = 0, l = args.nbFilters; i < l; i++) {
curFilter = filters[i].obj;
if (curFilter) {
curFilter.__onRequest(request);
}
}
}
if (request.delay > 0) {
// wait for the specified delay
ariaCoreTimer.addCallback({
fn : this._afterDelay,
args : args,
scope : this,
delay : request.delay
});
} else {
this._afterDelay(args);
}
}
|
javascript
|
function (unused, args) {
var filters = args.filters;
var request = args.request;
var curFilter;
// initialize the delay
request.delay = 0;
if (args.isResponse) {
for (var i = args.nbFilters - 1; i >= 0; i--) {
curFilter = filters[i].obj;
if (curFilter) {
curFilter.__onResponse(request);
}
}
} else {
for (var i = 0, l = args.nbFilters; i < l; i++) {
curFilter = filters[i].obj;
if (curFilter) {
curFilter.__onRequest(request);
}
}
}
if (request.delay > 0) {
// wait for the specified delay
ariaCoreTimer.addCallback({
fn : this._afterDelay,
args : args,
scope : this,
delay : request.delay
});
} else {
this._afterDelay(args);
}
}
|
[
"function",
"(",
"unused",
",",
"args",
")",
"{",
"var",
"filters",
"=",
"args",
".",
"filters",
";",
"var",
"request",
"=",
"args",
".",
"request",
";",
"var",
"curFilter",
";",
"request",
".",
"delay",
"=",
"0",
";",
"if",
"(",
"args",
".",
"isResponse",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"args",
".",
"nbFilters",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"curFilter",
"=",
"filters",
"[",
"i",
"]",
".",
"obj",
";",
"if",
"(",
"curFilter",
")",
"{",
"curFilter",
".",
"__onResponse",
"(",
"request",
")",
";",
"}",
"}",
"}",
"else",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"args",
".",
"nbFilters",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"curFilter",
"=",
"filters",
"[",
"i",
"]",
".",
"obj",
";",
"if",
"(",
"curFilter",
")",
"{",
"curFilter",
".",
"__onRequest",
"(",
"request",
")",
";",
"}",
"}",
"}",
"if",
"(",
"request",
".",
"delay",
">",
"0",
")",
"{",
"ariaCoreTimer",
".",
"addCallback",
"(",
"{",
"fn",
":",
"this",
".",
"_afterDelay",
",",
"args",
":",
"args",
",",
"scope",
":",
"this",
",",
"delay",
":",
"request",
".",
"delay",
"}",
")",
";",
"}",
"else",
"{",
"this",
".",
"_afterDelay",
"(",
"args",
")",
";",
"}",
"}"
] |
Effectively call filters in the right order.
@param {MultiTypes} unused
@param {Object} args object containing the following properties: isResponse, request, cb, filters and
nbFilters
@private
|
[
"Effectively",
"call",
"filters",
"in",
"the",
"right",
"order",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/IOFiltersMgr.js#L337-L369
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/core/IOFiltersMgr.js
|
function (cb) {
var filters = this._filters;
var curFilter;
var classpathsToLoad = [];
for (var i = 0, l = filters.length; i < l; i++) {
curFilter = filters[i];
if (curFilter.obj == null) {
classpathsToLoad.push(curFilter.filterClasspath);
}
}
Aria.load({
classes : classpathsToLoad,
oncomplete : {
fn : this._continueLoadingMissingFilters,
scope : this,
args : {
cb : cb,
filters : filters,
nbFilters : filters.length
}
}
});
}
|
javascript
|
function (cb) {
var filters = this._filters;
var curFilter;
var classpathsToLoad = [];
for (var i = 0, l = filters.length; i < l; i++) {
curFilter = filters[i];
if (curFilter.obj == null) {
classpathsToLoad.push(curFilter.filterClasspath);
}
}
Aria.load({
classes : classpathsToLoad,
oncomplete : {
fn : this._continueLoadingMissingFilters,
scope : this,
args : {
cb : cb,
filters : filters,
nbFilters : filters.length
}
}
});
}
|
[
"function",
"(",
"cb",
")",
"{",
"var",
"filters",
"=",
"this",
".",
"_filters",
";",
"var",
"curFilter",
";",
"var",
"classpathsToLoad",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"filters",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"curFilter",
"=",
"filters",
"[",
"i",
"]",
";",
"if",
"(",
"curFilter",
".",
"obj",
"==",
"null",
")",
"{",
"classpathsToLoad",
".",
"push",
"(",
"curFilter",
".",
"filterClasspath",
")",
";",
"}",
"}",
"Aria",
".",
"load",
"(",
"{",
"classes",
":",
"classpathsToLoad",
",",
"oncomplete",
":",
"{",
"fn",
":",
"this",
".",
"_continueLoadingMissingFilters",
",",
"scope",
":",
"this",
",",
"args",
":",
"{",
"cb",
":",
"cb",
",",
"filters",
":",
"filters",
",",
"nbFilters",
":",
"filters",
".",
"length",
"}",
"}",
"}",
")",
";",
"}"
] |
Load the filters which were added but not yet loaded.
@param {aria.core.CfgBeans:Callback} cb callback to be called when the load of filters is finished
@private
|
[
"Load",
"the",
"filters",
"which",
"were",
"added",
"but",
"not",
"yet",
"loaded",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/IOFiltersMgr.js#L388-L410
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/core/IOFiltersMgr.js
|
function (args) {
var filters = args.filters;
for (var i = 0, l = args.nbFilters; i < l; i++) {
var curFilter = filters[i];
// not that filterClasspath can be null if the filter was removed in the meantime.
if (curFilter.filterClasspath != null && curFilter.obj == null) {
curFilter.obj = Aria.getClassInstance(curFilter.filterClasspath, curFilter.initArgs);
this._filtersToBeLoaded--;
}
}
this.$callback(args.cb);
}
|
javascript
|
function (args) {
var filters = args.filters;
for (var i = 0, l = args.nbFilters; i < l; i++) {
var curFilter = filters[i];
// not that filterClasspath can be null if the filter was removed in the meantime.
if (curFilter.filterClasspath != null && curFilter.obj == null) {
curFilter.obj = Aria.getClassInstance(curFilter.filterClasspath, curFilter.initArgs);
this._filtersToBeLoaded--;
}
}
this.$callback(args.cb);
}
|
[
"function",
"(",
"args",
")",
"{",
"var",
"filters",
"=",
"args",
".",
"filters",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"args",
".",
"nbFilters",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"var",
"curFilter",
"=",
"filters",
"[",
"i",
"]",
";",
"if",
"(",
"curFilter",
".",
"filterClasspath",
"!=",
"null",
"&&",
"curFilter",
".",
"obj",
"==",
"null",
")",
"{",
"curFilter",
".",
"obj",
"=",
"Aria",
".",
"getClassInstance",
"(",
"curFilter",
".",
"filterClasspath",
",",
"curFilter",
".",
"initArgs",
")",
";",
"this",
".",
"_filtersToBeLoaded",
"--",
";",
"}",
"}",
"this",
".",
"$callback",
"(",
"args",
".",
"cb",
")",
";",
"}"
] |
Create instances of each filter once they are loaded.
@param {Object} args object containing the following properties: cb, filters, nbFilters
@private
|
[
"Create",
"instances",
"of",
"each",
"filter",
"once",
"they",
"are",
"loaded",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/core/IOFiltersMgr.js#L417-L428
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/container/Container.js
|
function (propagate) {
// PROFILING // this.$logTimestamp("updateContainerSize");
var cfg = this._cfg, domElt = this.getDom();
if (!domElt) {
return;
}
var widthConf = this._getWidthConf();
var heightConf = this._getHeightConf();
if (this._changedContainerSize || this._sizeConstraints) { // if we are bound to min and max size
if (this._changedContainerSize) {
// when maximized from start, widthMaximized will be empty initially, but it'll be adjusted later
var width = cfg.widthMaximized || cfg.width;
var height = cfg.heightMaximized || cfg.height;
var constrainedWidth = ariaUtilsMath.normalize(width, widthConf.min, widthConf.max);
var constrainedHeight = ariaUtilsMath.normalize(height, heightConf.min, heightConf.max);
domElt.style.width = width > -1 ? constrainedWidth + "px" : "";
domElt.style.height = height > -1 ? constrainedHeight + "px" : "";
if (this._frame) { // this is required if the frame is being shrinked
var frameWidth = width > -1 ? constrainedWidth : -1;
var frameHeight = height > -1 ? constrainedHeight : -1;
this._frame.resize(frameWidth, frameHeight);
}
}
var changed = ariaUtilsSize.setContrains(domElt, widthConf, heightConf);
if (changed && this._frame) {
this._frame.resize(changed.width, changed.height);
// throws a onchange event on parent
if (domElt.parentNode && propagate) {
aria.utils.Delegate.delegate(aria.DomEvent.getFakeEvent('contentchange', domElt.parentNode));
}
}
this._changedContainerSize = changed;
}
}
|
javascript
|
function (propagate) {
// PROFILING // this.$logTimestamp("updateContainerSize");
var cfg = this._cfg, domElt = this.getDom();
if (!domElt) {
return;
}
var widthConf = this._getWidthConf();
var heightConf = this._getHeightConf();
if (this._changedContainerSize || this._sizeConstraints) { // if we are bound to min and max size
if (this._changedContainerSize) {
// when maximized from start, widthMaximized will be empty initially, but it'll be adjusted later
var width = cfg.widthMaximized || cfg.width;
var height = cfg.heightMaximized || cfg.height;
var constrainedWidth = ariaUtilsMath.normalize(width, widthConf.min, widthConf.max);
var constrainedHeight = ariaUtilsMath.normalize(height, heightConf.min, heightConf.max);
domElt.style.width = width > -1 ? constrainedWidth + "px" : "";
domElt.style.height = height > -1 ? constrainedHeight + "px" : "";
if (this._frame) { // this is required if the frame is being shrinked
var frameWidth = width > -1 ? constrainedWidth : -1;
var frameHeight = height > -1 ? constrainedHeight : -1;
this._frame.resize(frameWidth, frameHeight);
}
}
var changed = ariaUtilsSize.setContrains(domElt, widthConf, heightConf);
if (changed && this._frame) {
this._frame.resize(changed.width, changed.height);
// throws a onchange event on parent
if (domElt.parentNode && propagate) {
aria.utils.Delegate.delegate(aria.DomEvent.getFakeEvent('contentchange', domElt.parentNode));
}
}
this._changedContainerSize = changed;
}
}
|
[
"function",
"(",
"propagate",
")",
"{",
"var",
"cfg",
"=",
"this",
".",
"_cfg",
",",
"domElt",
"=",
"this",
".",
"getDom",
"(",
")",
";",
"if",
"(",
"!",
"domElt",
")",
"{",
"return",
";",
"}",
"var",
"widthConf",
"=",
"this",
".",
"_getWidthConf",
"(",
")",
";",
"var",
"heightConf",
"=",
"this",
".",
"_getHeightConf",
"(",
")",
";",
"if",
"(",
"this",
".",
"_changedContainerSize",
"||",
"this",
".",
"_sizeConstraints",
")",
"{",
"if",
"(",
"this",
".",
"_changedContainerSize",
")",
"{",
"var",
"width",
"=",
"cfg",
".",
"widthMaximized",
"||",
"cfg",
".",
"width",
";",
"var",
"height",
"=",
"cfg",
".",
"heightMaximized",
"||",
"cfg",
".",
"height",
";",
"var",
"constrainedWidth",
"=",
"ariaUtilsMath",
".",
"normalize",
"(",
"width",
",",
"widthConf",
".",
"min",
",",
"widthConf",
".",
"max",
")",
";",
"var",
"constrainedHeight",
"=",
"ariaUtilsMath",
".",
"normalize",
"(",
"height",
",",
"heightConf",
".",
"min",
",",
"heightConf",
".",
"max",
")",
";",
"domElt",
".",
"style",
".",
"width",
"=",
"width",
">",
"-",
"1",
"?",
"constrainedWidth",
"+",
"\"px\"",
":",
"\"\"",
";",
"domElt",
".",
"style",
".",
"height",
"=",
"height",
">",
"-",
"1",
"?",
"constrainedHeight",
"+",
"\"px\"",
":",
"\"\"",
";",
"if",
"(",
"this",
".",
"_frame",
")",
"{",
"var",
"frameWidth",
"=",
"width",
">",
"-",
"1",
"?",
"constrainedWidth",
":",
"-",
"1",
";",
"var",
"frameHeight",
"=",
"height",
">",
"-",
"1",
"?",
"constrainedHeight",
":",
"-",
"1",
";",
"this",
".",
"_frame",
".",
"resize",
"(",
"frameWidth",
",",
"frameHeight",
")",
";",
"}",
"}",
"var",
"changed",
"=",
"ariaUtilsSize",
".",
"setContrains",
"(",
"domElt",
",",
"widthConf",
",",
"heightConf",
")",
";",
"if",
"(",
"changed",
"&&",
"this",
".",
"_frame",
")",
"{",
"this",
".",
"_frame",
".",
"resize",
"(",
"changed",
".",
"width",
",",
"changed",
".",
"height",
")",
";",
"if",
"(",
"domElt",
".",
"parentNode",
"&&",
"propagate",
")",
"{",
"aria",
".",
"utils",
".",
"Delegate",
".",
"delegate",
"(",
"aria",
".",
"DomEvent",
".",
"getFakeEvent",
"(",
"'contentchange'",
",",
"domElt",
".",
"parentNode",
")",
")",
";",
"}",
"}",
"this",
".",
"_changedContainerSize",
"=",
"changed",
";",
"}",
"}"
] |
Update the size of the container according to its width, height, minWidth, maxWidth, minHeight, maxHeight
properties.
@param {Boolean} propagate propagate change to parent
|
[
"Update",
"the",
"size",
"of",
"the",
"container",
"according",
"to",
"its",
"width",
"height",
"minWidth",
"maxWidth",
"minHeight",
"maxHeight",
"properties",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/container/Container.js#L113-L151
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/form/Input.js
|
function () {
var elt = this._getInputMarkupDomElt();
if (elt) {
this._initInputMarkup(elt);
}
var lbl = this._getInputLabelMarkupDomElt();
if (lbl) {
this._initLabelMarkup(lbl);
}
}
|
javascript
|
function () {
var elt = this._getInputMarkupDomElt();
if (elt) {
this._initInputMarkup(elt);
}
var lbl = this._getInputLabelMarkupDomElt();
if (lbl) {
this._initLabelMarkup(lbl);
}
}
|
[
"function",
"(",
")",
"{",
"var",
"elt",
"=",
"this",
".",
"_getInputMarkupDomElt",
"(",
")",
";",
"if",
"(",
"elt",
")",
"{",
"this",
".",
"_initInputMarkup",
"(",
"elt",
")",
";",
"}",
"var",
"lbl",
"=",
"this",
".",
"_getInputLabelMarkupDomElt",
"(",
")",
";",
"if",
"(",
"lbl",
")",
"{",
"this",
".",
"_initLabelMarkup",
"(",
"lbl",
")",
";",
"}",
"}"
] |
Override the Widget _init method
@protected
|
[
"Override",
"the",
"Widget",
"_init",
"method"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/Input.js#L145-L154
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/form/Input.js
|
function () {
var markup = [];
if (this._cfg.waiAria) {
var labelledBy = this._cfg.waiLabelledBy;
if (this._cfg.waiLabel) {
markup.push(' aria-label="' + ariaUtilsString.encodeForQuotedHTMLAttribute(this._cfg.waiLabel) + '" ');}
else if (!labelledBy) {
labelledBy = this._labelId;
}
if (labelledBy) {
markup.push(' aria-labelledby="' + ariaUtilsString.encodeForQuotedHTMLAttribute(labelledBy) + '" ');
}
if (this._cfg.waiDescribedBy) {
markup.push(' aria-describedby="' + ariaUtilsString.encodeForQuotedHTMLAttribute(this._cfg.waiDescribedBy) + '" ');
}
}
return markup.join('');
}
|
javascript
|
function () {
var markup = [];
if (this._cfg.waiAria) {
var labelledBy = this._cfg.waiLabelledBy;
if (this._cfg.waiLabel) {
markup.push(' aria-label="' + ariaUtilsString.encodeForQuotedHTMLAttribute(this._cfg.waiLabel) + '" ');}
else if (!labelledBy) {
labelledBy = this._labelId;
}
if (labelledBy) {
markup.push(' aria-labelledby="' + ariaUtilsString.encodeForQuotedHTMLAttribute(labelledBy) + '" ');
}
if (this._cfg.waiDescribedBy) {
markup.push(' aria-describedby="' + ariaUtilsString.encodeForQuotedHTMLAttribute(this._cfg.waiDescribedBy) + '" ');
}
}
return markup.join('');
}
|
[
"function",
"(",
")",
"{",
"var",
"markup",
"=",
"[",
"]",
";",
"if",
"(",
"this",
".",
"_cfg",
".",
"waiAria",
")",
"{",
"var",
"labelledBy",
"=",
"this",
".",
"_cfg",
".",
"waiLabelledBy",
";",
"if",
"(",
"this",
".",
"_cfg",
".",
"waiLabel",
")",
"{",
"markup",
".",
"push",
"(",
"' aria-label=\"'",
"+",
"ariaUtilsString",
".",
"encodeForQuotedHTMLAttribute",
"(",
"this",
".",
"_cfg",
".",
"waiLabel",
")",
"+",
"'\" '",
")",
";",
"}",
"else",
"if",
"(",
"!",
"labelledBy",
")",
"{",
"labelledBy",
"=",
"this",
".",
"_labelId",
";",
"}",
"if",
"(",
"labelledBy",
")",
"{",
"markup",
".",
"push",
"(",
"' aria-labelledby=\"'",
"+",
"ariaUtilsString",
".",
"encodeForQuotedHTMLAttribute",
"(",
"labelledBy",
")",
"+",
"'\" '",
")",
";",
"}",
"if",
"(",
"this",
".",
"_cfg",
".",
"waiDescribedBy",
")",
"{",
"markup",
".",
"push",
"(",
"' aria-describedby=\"'",
"+",
"ariaUtilsString",
".",
"encodeForQuotedHTMLAttribute",
"(",
"this",
".",
"_cfg",
".",
"waiDescribedBy",
")",
"+",
"'\" '",
")",
";",
"}",
"}",
"return",
"markup",
".",
"join",
"(",
"''",
")",
";",
"}"
] |
Returns the markup for the aria-label related attributes on a DOM element if accessibility is enabled.
@protected
|
[
"Returns",
"the",
"markup",
"for",
"the",
"aria",
"-",
"label",
"related",
"attributes",
"on",
"a",
"DOM",
"element",
"if",
"accessibility",
"is",
"enabled",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/Input.js#L167-L184
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/form/Input.js
|
function () {
var cfg = this._cfg, showLabel = (!cfg.hideLabel && !!cfg.label), idx;
if (showLabel) {
idx = ((cfg.labelPos === "right" && !this._fullWidth) || cfg.labelPos === "bottom") ? 0 : 1;
} else {
idx = 0;
}
var dom = this.getDom();
if (this._isIE7OrLess) {
dom = dom ? dom.firstChild : null;
}
return ariaUtilsDom.getDomElementChild(dom, idx);
}
|
javascript
|
function () {
var cfg = this._cfg, showLabel = (!cfg.hideLabel && !!cfg.label), idx;
if (showLabel) {
idx = ((cfg.labelPos === "right" && !this._fullWidth) || cfg.labelPos === "bottom") ? 0 : 1;
} else {
idx = 0;
}
var dom = this.getDom();
if (this._isIE7OrLess) {
dom = dom ? dom.firstChild : null;
}
return ariaUtilsDom.getDomElementChild(dom, idx);
}
|
[
"function",
"(",
")",
"{",
"var",
"cfg",
"=",
"this",
".",
"_cfg",
",",
"showLabel",
"=",
"(",
"!",
"cfg",
".",
"hideLabel",
"&&",
"!",
"!",
"cfg",
".",
"label",
")",
",",
"idx",
";",
"if",
"(",
"showLabel",
")",
"{",
"idx",
"=",
"(",
"(",
"cfg",
".",
"labelPos",
"===",
"\"right\"",
"&&",
"!",
"this",
".",
"_fullWidth",
")",
"||",
"cfg",
".",
"labelPos",
"===",
"\"bottom\"",
")",
"?",
"0",
":",
"1",
";",
"}",
"else",
"{",
"idx",
"=",
"0",
";",
"}",
"var",
"dom",
"=",
"this",
".",
"getDom",
"(",
")",
";",
"if",
"(",
"this",
".",
"_isIE7OrLess",
")",
"{",
"dom",
"=",
"dom",
"?",
"dom",
".",
"firstChild",
":",
"null",
";",
"}",
"return",
"ariaUtilsDom",
".",
"getDomElementChild",
"(",
"dom",
",",
"idx",
")",
";",
"}"
] |
Get the DOM elt associated to the Input Markup placeholder
@return {HTMLElement} the dom elt or null if not found
@protected
|
[
"Get",
"the",
"DOM",
"elt",
"associated",
"to",
"the",
"Input",
"Markup",
"placeholder"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/Input.js#L260-L272
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/form/Input.js
|
function () {
var cfg = this._cfg, showLabel = (!cfg.hideLabel && !!cfg.label);
if (showLabel) {
var dom = this.getDom();
if (this._isIE7OrLess) {
dom = dom ? dom.firstChild : null;
}
var elems = ariaUtilsDom.getDomElementsChildByTagName(dom, 'label');
if (elems) {
if (elems.length === 0) {
this.$logError(this.WIDGET_INPUT_NO_LABEL, []);
} else if (elems.length == 1) {
return elems[0];
} else {
this.$logError(this.WIDGET_INPUT_TOO_MANY_LABELS, []);
}
}
}
return null;
}
|
javascript
|
function () {
var cfg = this._cfg, showLabel = (!cfg.hideLabel && !!cfg.label);
if (showLabel) {
var dom = this.getDom();
if (this._isIE7OrLess) {
dom = dom ? dom.firstChild : null;
}
var elems = ariaUtilsDom.getDomElementsChildByTagName(dom, 'label');
if (elems) {
if (elems.length === 0) {
this.$logError(this.WIDGET_INPUT_NO_LABEL, []);
} else if (elems.length == 1) {
return elems[0];
} else {
this.$logError(this.WIDGET_INPUT_TOO_MANY_LABELS, []);
}
}
}
return null;
}
|
[
"function",
"(",
")",
"{",
"var",
"cfg",
"=",
"this",
".",
"_cfg",
",",
"showLabel",
"=",
"(",
"!",
"cfg",
".",
"hideLabel",
"&&",
"!",
"!",
"cfg",
".",
"label",
")",
";",
"if",
"(",
"showLabel",
")",
"{",
"var",
"dom",
"=",
"this",
".",
"getDom",
"(",
")",
";",
"if",
"(",
"this",
".",
"_isIE7OrLess",
")",
"{",
"dom",
"=",
"dom",
"?",
"dom",
".",
"firstChild",
":",
"null",
";",
"}",
"var",
"elems",
"=",
"ariaUtilsDom",
".",
"getDomElementsChildByTagName",
"(",
"dom",
",",
"'label'",
")",
";",
"if",
"(",
"elems",
")",
"{",
"if",
"(",
"elems",
".",
"length",
"===",
"0",
")",
"{",
"this",
".",
"$logError",
"(",
"this",
".",
"WIDGET_INPUT_NO_LABEL",
",",
"[",
"]",
")",
";",
"}",
"else",
"if",
"(",
"elems",
".",
"length",
"==",
"1",
")",
"{",
"return",
"elems",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"this",
".",
"$logError",
"(",
"this",
".",
"WIDGET_INPUT_TOO_MANY_LABELS",
",",
"[",
"]",
")",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] |
Get the DOM elt associated to the Label Markup HTML element
@return {HTMLElement} Label element
@protected
|
[
"Get",
"the",
"DOM",
"elt",
"associated",
"to",
"the",
"Label",
"Markup",
"HTML",
"element"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/Input.js#L278-L297
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/form/Input.js
|
function () {
var label = this.getLabel();
if (label) {
label.className = 'x' + this._skinnableClass + '_' + this._cfg.sclass + '_' + this._state + '_label'
+ this._getFloatingLabelClass();
}
}
|
javascript
|
function () {
var label = this.getLabel();
if (label) {
label.className = 'x' + this._skinnableClass + '_' + this._cfg.sclass + '_' + this._state + '_label'
+ this._getFloatingLabelClass();
}
}
|
[
"function",
"(",
")",
"{",
"var",
"label",
"=",
"this",
".",
"getLabel",
"(",
")",
";",
"if",
"(",
"label",
")",
"{",
"label",
".",
"className",
"=",
"'x'",
"+",
"this",
".",
"_skinnableClass",
"+",
"'_'",
"+",
"this",
".",
"_cfg",
".",
"sclass",
"+",
"'_'",
"+",
"this",
".",
"_state",
"+",
"'_label'",
"+",
"this",
".",
"_getFloatingLabelClass",
"(",
")",
";",
"}",
"}"
] |
Updates the CSS class of the label to match the current state of the widget.
|
[
"Updates",
"the",
"CSS",
"class",
"of",
"the",
"label",
"to",
"match",
"the",
"current",
"state",
"of",
"the",
"widget",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/Input.js#L382-L388
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/widgets/form/Input.js
|
function (cfg) {
var metaDataObject, localMetaDataObject, localMetaParam;
var toBind = this.automaticallyBindedProperties;
var value = null;
if (cfg) {
if (cfg.bind) {
value = cfg.bind.value; // get any binding on the value
// property
}
}
if (value && value.inside) { // only add the meta data convention
// if a value property has been
// bound
metaDataObject = ariaUtilsData._getMeta(value.inside, value.to, false);
if (!cfg.bind.error) {
cfg.bind.error = {
"inside" : metaDataObject,
"to" : "error"
};
}
if (!cfg.bind.errorMessages) {
cfg.bind.errorMessages = {
"inside" : metaDataObject,
"to" : "errorMessages"
};
}
// TODO: need a separation of each widget instances
// formatErrorMessages,
// currently no way to reference a widget after it has been
// disposed.
// Once this has been resolved then the widget instance
// reference can be used to create special meta to
// separate each widgets formatErrorMessages.
if (!cfg.bind.formatErrorMessages) {
cfg.bind.formatErrorMessages = {
"inside" : metaDataObject,
"to" : "formatErrorMessages"
};
}
if (!cfg.bind.requireFocus) {
cfg.bind.requireFocus = {
"inside" : metaDataObject,
"to" : "requireFocus"
};
}
if (cfg.inputMetaData) { // check to see if the inputMetaData
// convention is needed, then add
// the meta
// data for the rest of the automatic bindings
localMetaParam = "local:" + cfg.inputMetaData;
localMetaDataObject = metaDataObject[localMetaParam];
if (localMetaDataObject == null) {
localMetaDataObject = {};
metaDataObject[localMetaParam] = localMetaDataObject;
}
for (var i = 0; i < toBind.length; i++) {
if (!cfg.bind[toBind[i]]) { // only add a binding if one
// doesn't exist
cfg.bind[toBind[i]] = {
"inside" : localMetaDataObject,
"to" : toBind[i]
};
}
}
}
}
}
|
javascript
|
function (cfg) {
var metaDataObject, localMetaDataObject, localMetaParam;
var toBind = this.automaticallyBindedProperties;
var value = null;
if (cfg) {
if (cfg.bind) {
value = cfg.bind.value; // get any binding on the value
// property
}
}
if (value && value.inside) { // only add the meta data convention
// if a value property has been
// bound
metaDataObject = ariaUtilsData._getMeta(value.inside, value.to, false);
if (!cfg.bind.error) {
cfg.bind.error = {
"inside" : metaDataObject,
"to" : "error"
};
}
if (!cfg.bind.errorMessages) {
cfg.bind.errorMessages = {
"inside" : metaDataObject,
"to" : "errorMessages"
};
}
// TODO: need a separation of each widget instances
// formatErrorMessages,
// currently no way to reference a widget after it has been
// disposed.
// Once this has been resolved then the widget instance
// reference can be used to create special meta to
// separate each widgets formatErrorMessages.
if (!cfg.bind.formatErrorMessages) {
cfg.bind.formatErrorMessages = {
"inside" : metaDataObject,
"to" : "formatErrorMessages"
};
}
if (!cfg.bind.requireFocus) {
cfg.bind.requireFocus = {
"inside" : metaDataObject,
"to" : "requireFocus"
};
}
if (cfg.inputMetaData) { // check to see if the inputMetaData
// convention is needed, then add
// the meta
// data for the rest of the automatic bindings
localMetaParam = "local:" + cfg.inputMetaData;
localMetaDataObject = metaDataObject[localMetaParam];
if (localMetaDataObject == null) {
localMetaDataObject = {};
metaDataObject[localMetaParam] = localMetaDataObject;
}
for (var i = 0; i < toBind.length; i++) {
if (!cfg.bind[toBind[i]]) { // only add a binding if one
// doesn't exist
cfg.bind[toBind[i]] = {
"inside" : localMetaDataObject,
"to" : toBind[i]
};
}
}
}
}
}
|
[
"function",
"(",
"cfg",
")",
"{",
"var",
"metaDataObject",
",",
"localMetaDataObject",
",",
"localMetaParam",
";",
"var",
"toBind",
"=",
"this",
".",
"automaticallyBindedProperties",
";",
"var",
"value",
"=",
"null",
";",
"if",
"(",
"cfg",
")",
"{",
"if",
"(",
"cfg",
".",
"bind",
")",
"{",
"value",
"=",
"cfg",
".",
"bind",
".",
"value",
";",
"}",
"}",
"if",
"(",
"value",
"&&",
"value",
".",
"inside",
")",
"{",
"metaDataObject",
"=",
"ariaUtilsData",
".",
"_getMeta",
"(",
"value",
".",
"inside",
",",
"value",
".",
"to",
",",
"false",
")",
";",
"if",
"(",
"!",
"cfg",
".",
"bind",
".",
"error",
")",
"{",
"cfg",
".",
"bind",
".",
"error",
"=",
"{",
"\"inside\"",
":",
"metaDataObject",
",",
"\"to\"",
":",
"\"error\"",
"}",
";",
"}",
"if",
"(",
"!",
"cfg",
".",
"bind",
".",
"errorMessages",
")",
"{",
"cfg",
".",
"bind",
".",
"errorMessages",
"=",
"{",
"\"inside\"",
":",
"metaDataObject",
",",
"\"to\"",
":",
"\"errorMessages\"",
"}",
";",
"}",
"if",
"(",
"!",
"cfg",
".",
"bind",
".",
"formatErrorMessages",
")",
"{",
"cfg",
".",
"bind",
".",
"formatErrorMessages",
"=",
"{",
"\"inside\"",
":",
"metaDataObject",
",",
"\"to\"",
":",
"\"formatErrorMessages\"",
"}",
";",
"}",
"if",
"(",
"!",
"cfg",
".",
"bind",
".",
"requireFocus",
")",
"{",
"cfg",
".",
"bind",
".",
"requireFocus",
"=",
"{",
"\"inside\"",
":",
"metaDataObject",
",",
"\"to\"",
":",
"\"requireFocus\"",
"}",
";",
"}",
"if",
"(",
"cfg",
".",
"inputMetaData",
")",
"{",
"localMetaParam",
"=",
"\"local:\"",
"+",
"cfg",
".",
"inputMetaData",
";",
"localMetaDataObject",
"=",
"metaDataObject",
"[",
"localMetaParam",
"]",
";",
"if",
"(",
"localMetaDataObject",
"==",
"null",
")",
"{",
"localMetaDataObject",
"=",
"{",
"}",
";",
"metaDataObject",
"[",
"localMetaParam",
"]",
"=",
"localMetaDataObject",
";",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"toBind",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"cfg",
".",
"bind",
"[",
"toBind",
"[",
"i",
"]",
"]",
")",
"{",
"cfg",
".",
"bind",
"[",
"toBind",
"[",
"i",
"]",
"]",
"=",
"{",
"\"inside\"",
":",
"localMetaDataObject",
",",
"\"to\"",
":",
"toBind",
"[",
"i",
"]",
"}",
";",
"}",
"}",
"}",
"}",
"}"
] |
Apply the automatic bindings
@param {aria.widgets.CfgBeans:InputCfg|aria.widgets.CfgBeans:ActionWidgetCfg} cfg
@protected
|
[
"Apply",
"the",
"automatic",
"bindings"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/widgets/form/Input.js#L511-L580
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/utils/VisualFocus.js
|
function (element) {
if (this.__focusedElement) {
this.removeVisualFocus();
}
this.__focusedElement = element;
if (this.__style) {
var document = Aria.$window.document;
// for anchors and buttons it looks better to have the outline property set directly on them. Otherwise
// we look for the first span containing the element under focus
if (this.__focusedElement.tagName != "A" && this.__focusedElement.tagName != "BUTTON") {
for (var curNode = this.__focusedElement; curNode.tagName != "SPAN" && curNode != document.body; curNode = curNode.parentNode) {}
if (curNode != document.body) {
this.__outlinedElement = curNode;
}
} else {
this.__outlinedElement = this.__focusedElement;
}
if (this.__outlinedElement) {
// see comments on top of this.__previousOutline to uderstand the reason for this if statement
if (ariaCoreBrowser.isIE8) {
this.__previousStyle = this.__outlinedElement.style.cssText;// aria.utils.Dom.getStyle(this.__outlinedElement,
// "outline");
} else {
this.__previousStyle = (this.__outlinedElement.style.outline)
? this.__outlinedElement.style.outline
: "";
}
// finally ste the outline property in inline style attribute
this.__outlinedElement.style.outline = this.__style;
}
}
}
|
javascript
|
function (element) {
if (this.__focusedElement) {
this.removeVisualFocus();
}
this.__focusedElement = element;
if (this.__style) {
var document = Aria.$window.document;
// for anchors and buttons it looks better to have the outline property set directly on them. Otherwise
// we look for the first span containing the element under focus
if (this.__focusedElement.tagName != "A" && this.__focusedElement.tagName != "BUTTON") {
for (var curNode = this.__focusedElement; curNode.tagName != "SPAN" && curNode != document.body; curNode = curNode.parentNode) {}
if (curNode != document.body) {
this.__outlinedElement = curNode;
}
} else {
this.__outlinedElement = this.__focusedElement;
}
if (this.__outlinedElement) {
// see comments on top of this.__previousOutline to uderstand the reason for this if statement
if (ariaCoreBrowser.isIE8) {
this.__previousStyle = this.__outlinedElement.style.cssText;// aria.utils.Dom.getStyle(this.__outlinedElement,
// "outline");
} else {
this.__previousStyle = (this.__outlinedElement.style.outline)
? this.__outlinedElement.style.outline
: "";
}
// finally ste the outline property in inline style attribute
this.__outlinedElement.style.outline = this.__style;
}
}
}
|
[
"function",
"(",
"element",
")",
"{",
"if",
"(",
"this",
".",
"__focusedElement",
")",
"{",
"this",
".",
"removeVisualFocus",
"(",
")",
";",
"}",
"this",
".",
"__focusedElement",
"=",
"element",
";",
"if",
"(",
"this",
".",
"__style",
")",
"{",
"var",
"document",
"=",
"Aria",
".",
"$window",
".",
"document",
";",
"if",
"(",
"this",
".",
"__focusedElement",
".",
"tagName",
"!=",
"\"A\"",
"&&",
"this",
".",
"__focusedElement",
".",
"tagName",
"!=",
"\"BUTTON\"",
")",
"{",
"for",
"(",
"var",
"curNode",
"=",
"this",
".",
"__focusedElement",
";",
"curNode",
".",
"tagName",
"!=",
"\"SPAN\"",
"&&",
"curNode",
"!=",
"document",
".",
"body",
";",
"curNode",
"=",
"curNode",
".",
"parentNode",
")",
"{",
"}",
"if",
"(",
"curNode",
"!=",
"document",
".",
"body",
")",
"{",
"this",
".",
"__outlinedElement",
"=",
"curNode",
";",
"}",
"}",
"else",
"{",
"this",
".",
"__outlinedElement",
"=",
"this",
".",
"__focusedElement",
";",
"}",
"if",
"(",
"this",
".",
"__outlinedElement",
")",
"{",
"if",
"(",
"ariaCoreBrowser",
".",
"isIE8",
")",
"{",
"this",
".",
"__previousStyle",
"=",
"this",
".",
"__outlinedElement",
".",
"style",
".",
"cssText",
";",
"}",
"else",
"{",
"this",
".",
"__previousStyle",
"=",
"(",
"this",
".",
"__outlinedElement",
".",
"style",
".",
"outline",
")",
"?",
"this",
".",
"__outlinedElement",
".",
"style",
".",
"outline",
":",
"\"\"",
";",
"}",
"this",
".",
"__outlinedElement",
".",
"style",
".",
"outline",
"=",
"this",
".",
"__style",
";",
"}",
"}",
"}"
] |
Add visual focus. It sets the outline CSS property of the appropriate HTML Element to the value specified in
the appOutLineStyle of the application configuration
@param {HTMLElement} Element on focus
|
[
"Add",
"visual",
"focus",
".",
"It",
"sets",
"the",
"outline",
"CSS",
"property",
"of",
"the",
"appropriate",
"HTML",
"Element",
"to",
"the",
"value",
"specified",
"in",
"the",
"appOutLineStyle",
"of",
"the",
"application",
"configuration"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/VisualFocus.js#L119-L151
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/utils/VisualFocus.js
|
function () {
if (this.__style && this.__outlinedElement) {
// restore the previous outline
if (ariaCoreBrowser.isIE8) {
this.__outlinedElement.style.cssText = this.__previousStyle;
} else {
this.__outlinedElement.style.outline = this.__previousStyle;
}
this.__outlinedElement = null;
this.__previousStyle = null;
}
this.__focusedElement = null;
}
|
javascript
|
function () {
if (this.__style && this.__outlinedElement) {
// restore the previous outline
if (ariaCoreBrowser.isIE8) {
this.__outlinedElement.style.cssText = this.__previousStyle;
} else {
this.__outlinedElement.style.outline = this.__previousStyle;
}
this.__outlinedElement = null;
this.__previousStyle = null;
}
this.__focusedElement = null;
}
|
[
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"__style",
"&&",
"this",
".",
"__outlinedElement",
")",
"{",
"if",
"(",
"ariaCoreBrowser",
".",
"isIE8",
")",
"{",
"this",
".",
"__outlinedElement",
".",
"style",
".",
"cssText",
"=",
"this",
".",
"__previousStyle",
";",
"}",
"else",
"{",
"this",
".",
"__outlinedElement",
".",
"style",
".",
"outline",
"=",
"this",
".",
"__previousStyle",
";",
"}",
"this",
".",
"__outlinedElement",
"=",
"null",
";",
"this",
".",
"__previousStyle",
"=",
"null",
";",
"}",
"this",
".",
"__focusedElement",
"=",
"null",
";",
"}"
] |
Restore the outline to its previous value
|
[
"Restore",
"the",
"outline",
"to",
"its",
"previous",
"value"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/VisualFocus.js#L156-L168
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/utils/VisualFocus.js
|
function (newStyle) {
var styleToApply = (newStyle) ? newStyle : ariaUtilsEnvironmentVisualFocus.getAppOutlineStyle();
this.__style = !ariaCoreBrowser.isIE7 ? styleToApply : null;
this.__updateVisualFocus();
}
|
javascript
|
function (newStyle) {
var styleToApply = (newStyle) ? newStyle : ariaUtilsEnvironmentVisualFocus.getAppOutlineStyle();
this.__style = !ariaCoreBrowser.isIE7 ? styleToApply : null;
this.__updateVisualFocus();
}
|
[
"function",
"(",
"newStyle",
")",
"{",
"var",
"styleToApply",
"=",
"(",
"newStyle",
")",
"?",
"newStyle",
":",
"ariaUtilsEnvironmentVisualFocus",
".",
"getAppOutlineStyle",
"(",
")",
";",
"this",
".",
"__style",
"=",
"!",
"ariaCoreBrowser",
".",
"isIE7",
"?",
"styleToApply",
":",
"null",
";",
"this",
".",
"__updateVisualFocus",
"(",
")",
";",
"}"
] |
Changes the outline style. If the newStyle argument is not provided, the appOutlineStyle of the application
environment is chosen. This method is called after the "environmentChanged" event raised by
aria.core.environment.Environment
@param {String} newStyle [optional] outline style that you want to apply
|
[
"Changes",
"the",
"outline",
"style",
".",
"If",
"the",
"newStyle",
"argument",
"is",
"not",
"provided",
"the",
"appOutlineStyle",
"of",
"the",
"application",
"environment",
"is",
"chosen",
".",
"This",
"method",
"is",
"called",
"after",
"the",
"environmentChanged",
"event",
"raised",
"by",
"aria",
".",
"core",
".",
"environment",
".",
"Environment"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/utils/VisualFocus.js#L176-L180
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/tools/contextual/ContextualMenu.js
|
function (value) {
var document = Aria.$window.document;
if (value) {
// add event listeners if AriaSkin is available
// (required as it uses widgets)
// TODO: investigate to plug with event delegation
// when ready
if (aria.widgets && aria.widgets.AriaSkin) {
this._enabled = true;
eventUtils.addListener(document, "contextmenu", {
fn : this._onContextMenu,
scope : this
});
if (ariaCoreBrowser.isSafari) {
// PTR 04547842: Safari does not support the
// ctrlKey property on contextmenu event
// register the mouseup event to get this
// information
eventUtils.addListener(document, "mouseup", {
fn : this._onSafariMouseUp,
scope : this
});
}
}
} else {
this._enabled = false;
// remove event listeners
eventUtils.removeListener(document, "contextmenu", {
fn : this._onContextMenu
});
if (ariaCoreBrowser.isSafari) {
eventUtils.removeListener(document, "mouseup", {
fn : this._onSafariMouseUp
});
}
}
}
|
javascript
|
function (value) {
var document = Aria.$window.document;
if (value) {
// add event listeners if AriaSkin is available
// (required as it uses widgets)
// TODO: investigate to plug with event delegation
// when ready
if (aria.widgets && aria.widgets.AriaSkin) {
this._enabled = true;
eventUtils.addListener(document, "contextmenu", {
fn : this._onContextMenu,
scope : this
});
if (ariaCoreBrowser.isSafari) {
// PTR 04547842: Safari does not support the
// ctrlKey property on contextmenu event
// register the mouseup event to get this
// information
eventUtils.addListener(document, "mouseup", {
fn : this._onSafariMouseUp,
scope : this
});
}
}
} else {
this._enabled = false;
// remove event listeners
eventUtils.removeListener(document, "contextmenu", {
fn : this._onContextMenu
});
if (ariaCoreBrowser.isSafari) {
eventUtils.removeListener(document, "mouseup", {
fn : this._onSafariMouseUp
});
}
}
}
|
[
"function",
"(",
"value",
")",
"{",
"var",
"document",
"=",
"Aria",
".",
"$window",
".",
"document",
";",
"if",
"(",
"value",
")",
"{",
"if",
"(",
"aria",
".",
"widgets",
"&&",
"aria",
".",
"widgets",
".",
"AriaSkin",
")",
"{",
"this",
".",
"_enabled",
"=",
"true",
";",
"eventUtils",
".",
"addListener",
"(",
"document",
",",
"\"contextmenu\"",
",",
"{",
"fn",
":",
"this",
".",
"_onContextMenu",
",",
"scope",
":",
"this",
"}",
")",
";",
"if",
"(",
"ariaCoreBrowser",
".",
"isSafari",
")",
"{",
"eventUtils",
".",
"addListener",
"(",
"document",
",",
"\"mouseup\"",
",",
"{",
"fn",
":",
"this",
".",
"_onSafariMouseUp",
",",
"scope",
":",
"this",
"}",
")",
";",
"}",
"}",
"}",
"else",
"{",
"this",
".",
"_enabled",
"=",
"false",
";",
"eventUtils",
".",
"removeListener",
"(",
"document",
",",
"\"contextmenu\"",
",",
"{",
"fn",
":",
"this",
".",
"_onContextMenu",
"}",
")",
";",
"if",
"(",
"ariaCoreBrowser",
".",
"isSafari",
")",
"{",
"eventUtils",
".",
"removeListener",
"(",
"document",
",",
"\"mouseup\"",
",",
"{",
"fn",
":",
"this",
".",
"_onSafariMouseUp",
"}",
")",
";",
"}",
"}",
"}"
] |
Enables or disables the contextual menu. Shoule not be called directly. Instead, the value should be set
in the app environment.
@param {Boolean} value if true, it enables the contextual menu, if false, it disables it
@protected
|
[
"Enables",
"or",
"disables",
"the",
"contextual",
"menu",
".",
"Shoule",
"not",
"be",
"called",
"directly",
".",
"Instead",
"the",
"value",
"should",
"be",
"set",
"in",
"the",
"app",
"environment",
"."
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/tools/contextual/ContextualMenu.js#L144-L180
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/tools/contextual/ContextualMenu.js
|
function (event) {
if (!this._enabled) {
return;
}
event = new ariaDomEvent(event);
if (ariaCoreBrowser.isSafari) {
event.ctrlKey = this._safariCtrlKey;
}
// ctrl right click only
if (event.ctrlKey) {
// stop default behaviour, like opening real
// contextual menu
event.stopPropagation();
event.preventDefault();
var target = event.target;
this.__callContextualMenu(target, event.clientX, event.clientY);
event.$dispose();
return false;
}
event.$dispose();
}
|
javascript
|
function (event) {
if (!this._enabled) {
return;
}
event = new ariaDomEvent(event);
if (ariaCoreBrowser.isSafari) {
event.ctrlKey = this._safariCtrlKey;
}
// ctrl right click only
if (event.ctrlKey) {
// stop default behaviour, like opening real
// contextual menu
event.stopPropagation();
event.preventDefault();
var target = event.target;
this.__callContextualMenu(target, event.clientX, event.clientY);
event.$dispose();
return false;
}
event.$dispose();
}
|
[
"function",
"(",
"event",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_enabled",
")",
"{",
"return",
";",
"}",
"event",
"=",
"new",
"ariaDomEvent",
"(",
"event",
")",
";",
"if",
"(",
"ariaCoreBrowser",
".",
"isSafari",
")",
"{",
"event",
".",
"ctrlKey",
"=",
"this",
".",
"_safariCtrlKey",
";",
"}",
"if",
"(",
"event",
".",
"ctrlKey",
")",
"{",
"event",
".",
"stopPropagation",
"(",
")",
";",
"event",
".",
"preventDefault",
"(",
")",
";",
"var",
"target",
"=",
"event",
".",
"target",
";",
"this",
".",
"__callContextualMenu",
"(",
"target",
",",
"event",
".",
"clientX",
",",
"event",
".",
"clientY",
")",
";",
"event",
".",
"$dispose",
"(",
")",
";",
"return",
"false",
";",
"}",
"event",
".",
"$dispose",
"(",
")",
";",
"}"
] |
Handler for context menu call on document.body
@protected
@param {Event} event
|
[
"Handler",
"for",
"context",
"menu",
"call",
"on",
"document",
".",
"body"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/tools/contextual/ContextualMenu.js#L197-L217
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/tools/contextual/ContextualMenu.js
|
function (target, position) {
// look for existing Contextual menu
if (this._popup) {
aria.tools.contextual.ContextualMenu.close();
}
// first check the position else get positon from dom
// element
var domPosition = {};
if (!position) {
if (!target.$TemplateCtxt) {
domPosition = domUtils.getGeometry(target);
} else {
domPosition = {
x : 0,
y : 0
};
}
} else {
domPosition = position;
}
// look for template context
if (target.$TemplateCtxt) {
this._notifyFound(target, domPosition.x, domPosition.y);
return;
}
// Internal call to initiate the notify
this.__callContextualMenu(target, domPosition.x, domPosition.y);
return false;
}
|
javascript
|
function (target, position) {
// look for existing Contextual menu
if (this._popup) {
aria.tools.contextual.ContextualMenu.close();
}
// first check the position else get positon from dom
// element
var domPosition = {};
if (!position) {
if (!target.$TemplateCtxt) {
domPosition = domUtils.getGeometry(target);
} else {
domPosition = {
x : 0,
y : 0
};
}
} else {
domPosition = position;
}
// look for template context
if (target.$TemplateCtxt) {
this._notifyFound(target, domPosition.x, domPosition.y);
return;
}
// Internal call to initiate the notify
this.__callContextualMenu(target, domPosition.x, domPosition.y);
return false;
}
|
[
"function",
"(",
"target",
",",
"position",
")",
"{",
"if",
"(",
"this",
".",
"_popup",
")",
"{",
"aria",
".",
"tools",
".",
"contextual",
".",
"ContextualMenu",
".",
"close",
"(",
")",
";",
"}",
"var",
"domPosition",
"=",
"{",
"}",
";",
"if",
"(",
"!",
"position",
")",
"{",
"if",
"(",
"!",
"target",
".",
"$TemplateCtxt",
")",
"{",
"domPosition",
"=",
"domUtils",
".",
"getGeometry",
"(",
"target",
")",
";",
"}",
"else",
"{",
"domPosition",
"=",
"{",
"x",
":",
"0",
",",
"y",
":",
"0",
"}",
";",
"}",
"}",
"else",
"{",
"domPosition",
"=",
"position",
";",
"}",
"if",
"(",
"target",
".",
"$TemplateCtxt",
")",
"{",
"this",
".",
"_notifyFound",
"(",
"target",
",",
"domPosition",
".",
"x",
",",
"domPosition",
".",
"y",
")",
";",
"return",
";",
"}",
"this",
".",
"__callContextualMenu",
"(",
"target",
",",
"domPosition",
".",
"x",
",",
"domPosition",
".",
"y",
")",
";",
"return",
"false",
";",
"}"
] |
To call the Contexual Menu
@public
@param {aria.templates.TemplateCtxt} templateCtxt or DOM element
@param {Object} obj the object to set left and top position of the contextual menu
|
[
"To",
"call",
"the",
"Contexual",
"Menu"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/tools/contextual/ContextualMenu.js#L224-L255
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/tools/contextual/ContextualMenu.js
|
function (target, x, y) {
// check for template context
var previousTarget;
// look for the first template
var body = Aria.$window.document.body;
while (target && target != body && !target.__template) {
previousTarget = target;
target = target.parentNode;
}
// check for dom position
if (target == body && previousTarget) {
// prevousTarget might be a popup
// first check whether the PopupManager is loaded:
if (aria.popups && aria.popups.PopupManager) {
// then look for the popup:
var popup = aria.popups.PopupManager.getPopupFromDom(previousTarget);
if (popup && popup.section && popup.section.tplCtxt) {
// a popup was found
this._notifyFound(popup.section.tplCtxt, x, y);
}
}
} else if (target && target != body) {
this._notifyFound(contextManager.getFromDom(target.parentNode), x, y);
}
}
|
javascript
|
function (target, x, y) {
// check for template context
var previousTarget;
// look for the first template
var body = Aria.$window.document.body;
while (target && target != body && !target.__template) {
previousTarget = target;
target = target.parentNode;
}
// check for dom position
if (target == body && previousTarget) {
// prevousTarget might be a popup
// first check whether the PopupManager is loaded:
if (aria.popups && aria.popups.PopupManager) {
// then look for the popup:
var popup = aria.popups.PopupManager.getPopupFromDom(previousTarget);
if (popup && popup.section && popup.section.tplCtxt) {
// a popup was found
this._notifyFound(popup.section.tplCtxt, x, y);
}
}
} else if (target && target != body) {
this._notifyFound(contextManager.getFromDom(target.parentNode), x, y);
}
}
|
[
"function",
"(",
"target",
",",
"x",
",",
"y",
")",
"{",
"var",
"previousTarget",
";",
"var",
"body",
"=",
"Aria",
".",
"$window",
".",
"document",
".",
"body",
";",
"while",
"(",
"target",
"&&",
"target",
"!=",
"body",
"&&",
"!",
"target",
".",
"__template",
")",
"{",
"previousTarget",
"=",
"target",
";",
"target",
"=",
"target",
".",
"parentNode",
";",
"}",
"if",
"(",
"target",
"==",
"body",
"&&",
"previousTarget",
")",
"{",
"if",
"(",
"aria",
".",
"popups",
"&&",
"aria",
".",
"popups",
".",
"PopupManager",
")",
"{",
"var",
"popup",
"=",
"aria",
".",
"popups",
".",
"PopupManager",
".",
"getPopupFromDom",
"(",
"previousTarget",
")",
";",
"if",
"(",
"popup",
"&&",
"popup",
".",
"section",
"&&",
"popup",
".",
"section",
".",
"tplCtxt",
")",
"{",
"this",
".",
"_notifyFound",
"(",
"popup",
".",
"section",
".",
"tplCtxt",
",",
"x",
",",
"y",
")",
";",
"}",
"}",
"}",
"else",
"if",
"(",
"target",
"&&",
"target",
"!=",
"body",
")",
"{",
"this",
".",
"_notifyFound",
"(",
"contextManager",
".",
"getFromDom",
"(",
"target",
".",
"parentNode",
")",
",",
"x",
",",
"y",
")",
";",
"}",
"}"
] |
Internal function used to notify Contextual menu
@param {HTMLElement} elm DOM element
@param {Number} xpos
@param {Number} ypos
@private
|
[
"Internal",
"function",
"used",
"to",
"notify",
"Contextual",
"menu"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/tools/contextual/ContextualMenu.js#L263-L289
|
train
|
|
ariatemplates/ariatemplates
|
src/aria/tools/contextual/ContextualMenu.js
|
function (templateCtxt, xpos, ypos) {
// bridge is open -> inspector will handle this as well
var bridge = aria.tools.ToolsBridge;
if (bridge && bridge.isOpen) {
bridge.$raiseEvent({
name : "forwardEvent",
event : {
name : "ContextualTargetFound",
templateCtxt : templateCtxt
}
});
}
if (this._popup) {
return;
}
var popup = new ariaPopupsPopup();
this._popup = popup;
popup.$on({
"onAfterClose" : this._afterClose,
scope : this
});
// create a section on the founded template context
var section = templateCtxt.createSection({
fn : function (out) {
var tplWidget = new ariaWidgetsTemplate({
defaultTemplate : this._appEnvCfg.template,
moduleCtrl : {
classpath : this._appEnvCfg.moduleCtrl,
initArgs : {
templateCtxt : templateCtxt.$interface("aria.templates.ITemplateCtxt"),
driver : this.$interface("aria.tools.contextual.IContextualMenu")
}
}
}, templateCtxt, "NOLINE");
out.registerBehavior(tplWidget);
tplWidget.writeMarkup(out);
},
scope : this
});
popup.open({
section : section,
absolutePosition : {
top : ypos,
left : xpos
},
modal : true,
maskCssClass : "xDialogMask" /* uses the css class from the AriaSkin */,
preferredPositions : [{
reference : "bottom left",
popup : "top left"
}, {
reference : "bottom left",
popup : "top right"
}],
offset : {
top : 0,
left : 0
},
closeOnMouseClick : true,
closeOnMouseScroll : true
});
this.targetTemplateCtxt = templateCtxt;
}
|
javascript
|
function (templateCtxt, xpos, ypos) {
// bridge is open -> inspector will handle this as well
var bridge = aria.tools.ToolsBridge;
if (bridge && bridge.isOpen) {
bridge.$raiseEvent({
name : "forwardEvent",
event : {
name : "ContextualTargetFound",
templateCtxt : templateCtxt
}
});
}
if (this._popup) {
return;
}
var popup = new ariaPopupsPopup();
this._popup = popup;
popup.$on({
"onAfterClose" : this._afterClose,
scope : this
});
// create a section on the founded template context
var section = templateCtxt.createSection({
fn : function (out) {
var tplWidget = new ariaWidgetsTemplate({
defaultTemplate : this._appEnvCfg.template,
moduleCtrl : {
classpath : this._appEnvCfg.moduleCtrl,
initArgs : {
templateCtxt : templateCtxt.$interface("aria.templates.ITemplateCtxt"),
driver : this.$interface("aria.tools.contextual.IContextualMenu")
}
}
}, templateCtxt, "NOLINE");
out.registerBehavior(tplWidget);
tplWidget.writeMarkup(out);
},
scope : this
});
popup.open({
section : section,
absolutePosition : {
top : ypos,
left : xpos
},
modal : true,
maskCssClass : "xDialogMask" /* uses the css class from the AriaSkin */,
preferredPositions : [{
reference : "bottom left",
popup : "top left"
}, {
reference : "bottom left",
popup : "top right"
}],
offset : {
top : 0,
left : 0
},
closeOnMouseClick : true,
closeOnMouseScroll : true
});
this.targetTemplateCtxt = templateCtxt;
}
|
[
"function",
"(",
"templateCtxt",
",",
"xpos",
",",
"ypos",
")",
"{",
"var",
"bridge",
"=",
"aria",
".",
"tools",
".",
"ToolsBridge",
";",
"if",
"(",
"bridge",
"&&",
"bridge",
".",
"isOpen",
")",
"{",
"bridge",
".",
"$raiseEvent",
"(",
"{",
"name",
":",
"\"forwardEvent\"",
",",
"event",
":",
"{",
"name",
":",
"\"ContextualTargetFound\"",
",",
"templateCtxt",
":",
"templateCtxt",
"}",
"}",
")",
";",
"}",
"if",
"(",
"this",
".",
"_popup",
")",
"{",
"return",
";",
"}",
"var",
"popup",
"=",
"new",
"ariaPopupsPopup",
"(",
")",
";",
"this",
".",
"_popup",
"=",
"popup",
";",
"popup",
".",
"$on",
"(",
"{",
"\"onAfterClose\"",
":",
"this",
".",
"_afterClose",
",",
"scope",
":",
"this",
"}",
")",
";",
"var",
"section",
"=",
"templateCtxt",
".",
"createSection",
"(",
"{",
"fn",
":",
"function",
"(",
"out",
")",
"{",
"var",
"tplWidget",
"=",
"new",
"ariaWidgetsTemplate",
"(",
"{",
"defaultTemplate",
":",
"this",
".",
"_appEnvCfg",
".",
"template",
",",
"moduleCtrl",
":",
"{",
"classpath",
":",
"this",
".",
"_appEnvCfg",
".",
"moduleCtrl",
",",
"initArgs",
":",
"{",
"templateCtxt",
":",
"templateCtxt",
".",
"$interface",
"(",
"\"aria.templates.ITemplateCtxt\"",
")",
",",
"driver",
":",
"this",
".",
"$interface",
"(",
"\"aria.tools.contextual.IContextualMenu\"",
")",
"}",
"}",
"}",
",",
"templateCtxt",
",",
"\"NOLINE\"",
")",
";",
"out",
".",
"registerBehavior",
"(",
"tplWidget",
")",
";",
"tplWidget",
".",
"writeMarkup",
"(",
"out",
")",
";",
"}",
",",
"scope",
":",
"this",
"}",
")",
";",
"popup",
".",
"open",
"(",
"{",
"section",
":",
"section",
",",
"absolutePosition",
":",
"{",
"top",
":",
"ypos",
",",
"left",
":",
"xpos",
"}",
",",
"modal",
":",
"true",
",",
"maskCssClass",
":",
"\"xDialogMask\"",
",",
"preferredPositions",
":",
"[",
"{",
"reference",
":",
"\"bottom left\"",
",",
"popup",
":",
"\"top left\"",
"}",
",",
"{",
"reference",
":",
"\"bottom left\"",
",",
"popup",
":",
"\"top right\"",
"}",
"]",
",",
"offset",
":",
"{",
"top",
":",
"0",
",",
"left",
":",
"0",
"}",
",",
"closeOnMouseClick",
":",
"true",
",",
"closeOnMouseScroll",
":",
"true",
"}",
")",
";",
"this",
".",
"targetTemplateCtxt",
"=",
"templateCtxt",
";",
"}"
] |
Handle what to do when a target for inspection if retrieve
@protected
@param {aria.templates.TemplateCtxt} templateCtxt
@param {Number} xpos
@param {Number} ypos
|
[
"Handle",
"what",
"to",
"do",
"when",
"a",
"target",
"for",
"inspection",
"if",
"retrieve"
] |
7ed5d065818ae159bf361c9dfb209b1cf3883c90
|
https://github.com/ariatemplates/ariatemplates/blob/7ed5d065818ae159bf361c9dfb209b1cf3883c90/src/aria/tools/contextual/ContextualMenu.js#L310-L380
|
train
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.