r3-legacy/src/r3-a-3-api-component.js

68 lines
1.4 KiB
JavaScript
Raw Normal View History

2019-07-24 08:08:02 +02:00
/**
* API Component Interface - Do not construct objects of this type directly
* @param parent
* @param id
* @param name
2019-08-10 19:48:08 +02:00
* @param register
* @param selected
2019-07-24 08:08:02 +02:00
* @constructor
*/
R3.API.Component = function(
parent,
id,
2019-08-10 19:48:08 +02:00
name,
register,
selected
2019-07-24 08:08:02 +02:00
) {
if (R3.Utils.UndefinedOrNull(parent)) {
parent = null;
}
this.parent = parent;
if (R3.Utils.UndefinedOrNull(id)) {
id = R3.Utils.RandomId();
}
this.id = id;
2019-10-06 21:11:18 +02:00
this.componentType = R3.GetComponentType(this);
2019-07-24 08:08:02 +02:00
if (R3.Utils.UndefinedOrNull(name)) {
name = R3.Component.GetComponentFriendlyName(this.componentType) + ' (' + this.id + ')';
}
this.name = name;
2019-08-10 19:48:08 +02:00
if (R3.Utils.UndefinedOrNull(register)) {
register = true;
}
this.register = register;
if (R3.Utils.UndefinedOrNull(selected)) {
selected = false;
}
this.selected = selected;
2019-10-15 22:21:34 +02:00
2019-07-24 08:08:02 +02:00
};
R3.API.Component.prototype.constructor = R3.API.Component;
2019-08-07 05:17:41 +02:00
/**
* Wrapper for R3.Utils.GetFirstParent
* @param constructor
* @returns {*}
*/
R3.API.Component.prototype.getFirstParent = function(constructor) {
2019-10-15 22:21:34 +02:00
return R3.Utils.GetFirstParent(this, constructor);
2019-08-07 05:17:41 +02:00
};
2019-07-24 14:45:42 +02:00
2019-08-07 05:17:41 +02:00
/**
* Wrapper for R3.Utils.GetParent
* @param property
* @param index
* @param constructor
* @returns {*}
*/
R3.API.Component.getParent = function(property, index, constructor) {
2019-10-15 22:21:34 +02:00
return R3.Utils.GetParent(this, property, index, constructor);
2019-07-24 14:45:42 +02:00
};