123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- /*global define*/
- define([
- '../../Core/defined',
- '../../Core/defineProperties',
- '../../Core/destroyObject',
- '../../Core/DeveloperError',
- '../../ThirdParty/knockout',
- '../getElement',
- './HomeButtonViewModel'
- ], function(
- defined,
- defineProperties,
- destroyObject,
- DeveloperError,
- knockout,
- getElement,
- HomeButtonViewModel) {
- "use strict";
- /**
- * A single button widget for returning to the default camera view of the current scene.
- *
- * @alias HomeButton
- * @constructor
- *
- * @param {Element|String} container The DOM element or ID that will contain the widget.
- * @param {Scene} scene The Scene instance to use.
- * @param {Number} [duration] The time, in seconds, it takes to complete the camera flight home.
- */
- var HomeButton = function(container, scene, duration) {
- //>>includeStart('debug', pragmas.debug);
- if (!defined(container)) {
- throw new DeveloperError('container is required.');
- }
- //>>includeEnd('debug');
- container = getElement(container);
- var viewModel = new HomeButtonViewModel(scene, duration);
- viewModel._svgPath = 'M14,4l-10,8.75h20l-4.25-3.7188v-4.6562h-2.812v2.1875l-2.938-2.5625zm-7.0938,9.906v10.094h14.094v-10.094h-14.094zm2.1876,2.313h3.3122v4.25h-3.3122v-4.25zm5.8442,1.281h3.406v6.438h-3.406v-6.438z';
- var element = document.createElement('button');
- element.type = 'button';
- element.className = 'cesium-button cesium-toolbar-button cesium-home-button';
- element.setAttribute('data-bind', '\
- attr: { title: tooltip },\
- click: command,\
- cesiumSvgPath: { path: _svgPath, width: 28, height: 28 }');
- container.appendChild(element);
- knockout.applyBindings(viewModel, element);
- this._container = container;
- this._viewModel = viewModel;
- this._element = element;
- };
- defineProperties(HomeButton.prototype, {
- /**
- * Gets the parent container.
- * @memberof HomeButton.prototype
- *
- * @type {Element}
- */
- container : {
- get : function() {
- return this._container;
- }
- },
- /**
- * Gets the view model.
- * @memberof HomeButton.prototype
- *
- * @type {HomeButtonViewModel}
- */
- viewModel : {
- get : function() {
- return this._viewModel;
- }
- }
- });
- /**
- * @returns {Boolean} true if the object has been destroyed, false otherwise.
- */
- HomeButton.prototype.isDestroyed = function() {
- return false;
- };
- /**
- * Destroys the widget. Should be called if permanently
- * removing the widget from layout.
- */
- HomeButton.prototype.destroy = function() {
- knockout.cleanNode(this._element);
- this._container.removeChild(this._element);
- return destroyObject(this);
- };
- return HomeButton;
- });
|