UNPKG

cesium-navigation-es6

Version:
105 lines (90 loc) 2.45 kB
import Cesium from 'cesium/Cesium' var defined = Cesium.defined var defineProperties = Cesium.defineProperties var DeveloperError = Cesium.DeveloperError var Knockout = Cesium.knockout /** * The view-model for a control in the user interface * * @alias UserInterfaceControl * @constructor * @abstract * * @param {Terria} terria The Terria instance. */ var UserInterfaceControl = function (terria) { if (!defined(terria)) { throw new DeveloperError('terria is required') } this._terria = terria /** * Gets or sets the name of the control which is set as the controls title. * This property is observable. * @type {String} */ this.name = 'Unnamed Control' /** * Gets or sets the text to be displayed in the UI control. * This property is observable. * @type {String} */ this.text = undefined /** * Gets or sets the svg icon of the control. This property is observable. * @type {Object} */ this.svgIcon = undefined /** * Gets or sets the height of the svg icon. This property is observable. * @type {Integer} */ this.svgHeight = undefined /** * Gets or sets the width of the svg icon. This property is observable. * @type {Integer} */ this.svgWidth = undefined /** * Gets or sets the CSS class of the control. This property is observable. * @type {String} */ this.cssClass = undefined /** * Gets or sets the property describing whether or not the control is in the active state. * This property is observable. * @type {Boolean} */ this.isActive = false Knockout.track(this, ['name', 'svgIcon', 'svgHeight', 'svgWidth', 'cssClass', 'isActive']) } defineProperties(UserInterfaceControl.prototype, { /** * Gets the Terria instance. * @memberOf UserInterfaceControl.prototype * @type {Terria} */ terria: { get: function () { return this._terria } }, /** * Gets a value indicating whether this button has text associated with it. * @type {Object} */ hasText: { get: function () { return defined(this.text) && typeof this.text === 'string' } } }) /** * When implemented in a derived class, performs an action when the user clicks * on this control. * @abstract * @protected */ UserInterfaceControl.prototype.activate = function () { throw new DeveloperError('activate must be implemented in the derived class.') } export default UserInterfaceControl