|
| 1 | +/***************************************************************************** |
| 2 | + * Open MCT Web, Copyright (c) 2014-2015, United States Government |
| 3 | + * as represented by the Administrator of the National Aeronautics and Space |
| 4 | + * Administration. All rights reserved. |
| 5 | + * |
| 6 | + * Open MCT Web is licensed under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0. |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 13 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 14 | + * License for the specific language governing permissions and limitations |
| 15 | + * under the License. |
| 16 | + * |
| 17 | + * Open MCT Web includes source code licensed under additional open source |
| 18 | + * licenses. See the Open Source Licenses file (LICENSES.md) included with |
| 19 | + * this source code distribution or the Licensing information page available |
| 20 | + * at runtime from the About dialog for additional information. |
| 21 | + *****************************************************************************/ |
| 22 | + |
| 23 | +define( |
| 24 | + ["zepto"], |
| 25 | + function ($) { |
| 26 | + |
| 27 | + /** |
| 28 | + * The mct-conductor-axis renders a horizontal axis with regular |
| 29 | + * labelled 'ticks'. It requires 'start' and 'end' integer values to |
| 30 | + * be specified as attributes. |
| 31 | + */ |
| 32 | + function TimeOfInterestController($scope, conductor, formatService) { |
| 33 | + this.conductor = conductor; |
| 34 | + this.formatService = formatService; |
| 35 | + this.format = undefined; |
| 36 | + this.toiText = undefined; |
| 37 | + |
| 38 | + //Bind all class functions to 'this' |
| 39 | + Object.keys(TimeOfInterestController.prototype).filter(function (key) { |
| 40 | + return typeof TimeOfInterestController.prototype[key] === 'function'; |
| 41 | + }).forEach(function (key) { |
| 42 | + this[key] = TimeOfInterestController.prototype[key].bind(this); |
| 43 | + }.bind(this)); |
| 44 | + |
| 45 | + this.conductor.on('timeOfInterest', this.changeTimeOfInterest); |
| 46 | + this.conductor.on('timeSystem', this.changeTimeSystem); |
| 47 | + if (conductor.timeSystem()) { |
| 48 | + this.changeTimeSystem(conductor.timeSystem()); |
| 49 | + } |
| 50 | + |
| 51 | + $scope.$on('$destroy', this.destroy); |
| 52 | + |
| 53 | + } |
| 54 | + |
| 55 | + TimeOfInterestController.prototype.changeTimeOfInterest = function (toi) { |
| 56 | + this.pinned = (toi !== undefined); |
| 57 | + }; |
| 58 | + |
| 59 | + TimeOfInterestController.prototype.changeTimeSystem = function (timeSystem) { |
| 60 | + this.format = this.formatService.getFormat(timeSystem.formats()[0]); |
| 61 | + }; |
| 62 | + |
| 63 | + TimeOfInterestController.prototype.destroy = function () { |
| 64 | + this.conductor.off('timeOfInterest', this.setOffsetFromBounds); |
| 65 | + this.conductor.off('timeSystem', this.changeTimeSystem); |
| 66 | + }; |
| 67 | + |
| 68 | + |
| 69 | + return TimeOfInterestController; |
| 70 | + } |
| 71 | +); |
0 commit comments