From 660757fc1c41b8b28da1423d3ed849b074224fe3 Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 14 Oct 2016 14:38:46 -0700 Subject: [PATCH] Added TimeOfInterestController --- .../src/ui/TimeOfInterestController.js | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 platform/features/conductor-v2/conductor/src/ui/TimeOfInterestController.js diff --git a/platform/features/conductor-v2/conductor/src/ui/TimeOfInterestController.js b/platform/features/conductor-v2/conductor/src/ui/TimeOfInterestController.js new file mode 100644 index 00000000000..ff9bc2ec89e --- /dev/null +++ b/platform/features/conductor-v2/conductor/src/ui/TimeOfInterestController.js @@ -0,0 +1,71 @@ +/***************************************************************************** + * Open MCT Web, Copyright (c) 2014-2015, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT Web is licensed under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * Open MCT Web includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ + +define( + ["zepto"], + function ($) { + + /** + * The mct-conductor-axis renders a horizontal axis with regular + * labelled 'ticks'. It requires 'start' and 'end' integer values to + * be specified as attributes. + */ + function TimeOfInterestController($scope, conductor, formatService) { + this.conductor = conductor; + this.formatService = formatService; + this.format = undefined; + this.toiText = undefined; + + //Bind all class functions to 'this' + Object.keys(TimeOfInterestController.prototype).filter(function (key) { + return typeof TimeOfInterestController.prototype[key] === 'function'; + }).forEach(function (key) { + this[key] = TimeOfInterestController.prototype[key].bind(this); + }.bind(this)); + + this.conductor.on('timeOfInterest', this.changeTimeOfInterest); + this.conductor.on('timeSystem', this.changeTimeSystem); + if (conductor.timeSystem()) { + this.changeTimeSystem(conductor.timeSystem()); + } + + $scope.$on('$destroy', this.destroy); + + } + + TimeOfInterestController.prototype.changeTimeOfInterest = function (toi) { + this.pinned = (toi !== undefined); + }; + + TimeOfInterestController.prototype.changeTimeSystem = function (timeSystem) { + this.format = this.formatService.getFormat(timeSystem.formats()[0]); + }; + + TimeOfInterestController.prototype.destroy = function () { + this.conductor.off('timeOfInterest', this.setOffsetFromBounds); + this.conductor.off('timeSystem', this.changeTimeSystem); + }; + + + return TimeOfInterestController; + } +);