mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 00:24:21 +02:00
Squashed 'lib/vis/' content from commit 1d029ca
git-subtree-dir: lib/vis git-subtree-split: 1d029cab7b527f3b292e95d550efbf784dac8699
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Prototype for visual components
|
||||
* @param {{dom: Object, domProps: Object, emitter: Emitter, range: Range}} [body]
|
||||
* @param {Object} [options]
|
||||
*/
|
||||
function Component (body, options) {
|
||||
this.options = null;
|
||||
this.props = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set options for the component. The new options will be merged into the
|
||||
* current options.
|
||||
* @param {Object} options
|
||||
*/
|
||||
Component.prototype.setOptions = function(options) {
|
||||
if (options) {
|
||||
util.extend(this.options, options);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Repaint the component
|
||||
* @return {boolean} Returns true if the component is resized
|
||||
*/
|
||||
Component.prototype.redraw = function() {
|
||||
// should be implemented by the component
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Destroy the component. Cleanup DOM and event listeners
|
||||
*/
|
||||
Component.prototype.destroy = function() {
|
||||
// should be implemented by the component
|
||||
};
|
||||
|
||||
/**
|
||||
* Test whether the component is resized since the last time _isResized() was
|
||||
* called.
|
||||
* @return {Boolean} Returns true if the component is resized
|
||||
* @protected
|
||||
*/
|
||||
Component.prototype._isResized = function() {
|
||||
var resized = (this.props._previousWidth !== this.props.width ||
|
||||
this.props._previousHeight !== this.props.height);
|
||||
|
||||
this.props._previousWidth = this.props.width;
|
||||
this.props._previousHeight = this.props.height;
|
||||
|
||||
return resized;
|
||||
};
|
||||
|
||||
module.exports = Component;
|
||||
Reference in New Issue
Block a user