mirror of
https://github.com/nasa/openmct.git
synced 2025-01-01 10:56:41 +00:00
[Fixed Position] Begin adding element proxy classes
Begin adding proxy classes to allow the toolbar to interact with elements in a fixed position view, WTD-879.
This commit is contained in:
parent
466a169562
commit
f24f62dedc
26
platform/features/layout/src/elements/Accessor.js
Normal file
26
platform/features/layout/src/elements/Accessor.js
Normal file
@ -0,0 +1,26 @@
|
||||
/*global define*/
|
||||
|
||||
define(
|
||||
[],
|
||||
function () {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Utility function for creating getter-setter functions,
|
||||
* since these are frequently useful for element proxies.
|
||||
* @constructor
|
||||
* @param {Object} object the object to get/set values upon
|
||||
* @param {string} key the property to get/set
|
||||
*/
|
||||
function Accessor(object, key) {
|
||||
return function (value) {
|
||||
if (arguments.length > 0) {
|
||||
object[key] = value;
|
||||
}
|
||||
return value;
|
||||
};
|
||||
}
|
||||
|
||||
return Accessor;
|
||||
}
|
||||
);
|
12
platform/features/layout/src/elements/ElementProxies.js
Normal file
12
platform/features/layout/src/elements/ElementProxies.js
Normal file
@ -0,0 +1,12 @@
|
||||
/*global define*/
|
||||
|
||||
define(
|
||||
['./TelemetryProxy'],
|
||||
function (TelemetryProxy) {
|
||||
"use strict";
|
||||
|
||||
return {
|
||||
"fixed.telemetry": TelemetryProxy
|
||||
};
|
||||
}
|
||||
);
|
35
platform/features/layout/src/elements/ElementProxy.js
Normal file
35
platform/features/layout/src/elements/ElementProxy.js
Normal file
@ -0,0 +1,35 @@
|
||||
/*global define*/
|
||||
|
||||
define(
|
||||
['./Accessor'],
|
||||
function (Accessor) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Abstract superclass for other classes which provide useful
|
||||
* interfaces upon an elements in a fixed position view.
|
||||
* This handles the generic operations (e.g. remove) so that
|
||||
* subclasses only need to implement element-specific behaviors.
|
||||
* @constructor
|
||||
* @param element the telemetry element
|
||||
* @param index the element's index within its array
|
||||
* @param {Array} elements the full array of elements
|
||||
*/
|
||||
function ElementProxy(element, index, elements) {
|
||||
return {
|
||||
x: new Accessor(element, 'x'),
|
||||
y: new Accessor(element, 'y'),
|
||||
z: new Accessor(element, 'z'),
|
||||
width: new Accessor(element, 'width'),
|
||||
height: new Accessor(element, 'height'),
|
||||
remove: function () {
|
||||
if (elements[index] === element) {
|
||||
elements.splice(index, 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return ElementProxy;
|
||||
}
|
||||
);
|
21
platform/features/layout/src/elements/TelemetryProxy.js
Normal file
21
platform/features/layout/src/elements/TelemetryProxy.js
Normal file
@ -0,0 +1,21 @@
|
||||
/*global define*/
|
||||
|
||||
define(
|
||||
['./ElementProxy'],
|
||||
function (ElementProxy) {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function TelemetryProxy(element, index, elements) {
|
||||
var proxy = new ElementProxy(element, index, elements);
|
||||
|
||||
proxy.id = element.id;
|
||||
|
||||
return proxy;
|
||||
}
|
||||
|
||||
return TelemetryProxy;
|
||||
}
|
||||
);
|
Loading…
Reference in New Issue
Block a user