diff --git a/platform/features/hyperlink/bundle.js b/platform/features/hyperlink/bundle.js new file mode 100644 index 0000000000..8a68538420 --- /dev/null +++ b/platform/features/hyperlink/bundle.js @@ -0,0 +1,133 @@ +/***************************************************************************** + * Open MCT, Copyright (c) 2009-2016, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT 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 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([ + './src/HyperlinkController', + 'legacyRegistry', + 'text!./res/templates/hyperlink.html' +], function ( + HyperlinkController, + legacyRegistry, + hyperlinkTemplate +) { + legacyRegistry.register("platform/features/hyperlink", { + "name": "Hyperlink", + "description": "Insert a hyperlink to reference a link", + "extensions": { + "types": [ + { + "key": "hyperlink", + "name": "Hyperlink", + "cssClass": "icon-page", + "description": "A hyperlink to redirect to a different link", + "features": ["creation"], + "properties": [ + { + "key": "url", + "name": "URL", + "control": "textfield", + "pattern": "^(ftp|https?)\\:\\/\\/", + "required": true, + "cssClass": "l-input-lg" + }, + { + "key": "displayText", + "name": "Text to Display", + "control": "textfield", + "required": true, + "cssClass": "l-input-lg" + }, + { + "key": "showTitle", + "control": "checkbox", + "value": false + },{ + "key": "displayFormat", + "name": "Display Format", + "control": "composite", + "items": [ + { + "control": "select", + "options": [ + { + "name": "Link", + "value": "link" + }, + { + "value": "button", + "name": "Button" + } + ], + "cssClass": "l-inline" + } + ] + }, + { + "key": "openNewTab", + "name": "Tab to Open Hyperlink", + "control": "composite", + "items": [ + { + "control": "select", + "options": [ + { + "name": "Open in this tab", + "value": "thisTab" + }, + { + "value": "newTab", + "name": "Open in a new tab" + } + ], + "cssClass": "l-inline" + } + ] + } + ], + "model": { + "displayFormat": ["link"], + "openNewTab": ["thisTab"], + "showTitle": false + } + + } + ], + "views": [ + { + "key": "hyperlink", + "type": "hyperlink", + "cssClass": "icon-check", + "name": "icon", + "template": hyperlinkTemplate, + "editable": false + } + ], + "controllers": [ + { + "key": "HyperlinkController", + "implementation": HyperlinkController, + "depends": ["$scope"] + } + ] + } + }); +}); diff --git a/platform/features/hyperlink/res/templates/hyperlink.html b/platform/features/hyperlink/res/templates/hyperlink.html new file mode 100644 index 0000000000..52039872d3 --- /dev/null +++ b/platform/features/hyperlink/res/templates/hyperlink.html @@ -0,0 +1,31 @@ + + diff --git a/platform/features/hyperlink/src/HyperlinkController.js b/platform/features/hyperlink/src/HyperlinkController.js new file mode 100644 index 0000000000..5fc8eaec24 --- /dev/null +++ b/platform/features/hyperlink/src/HyperlinkController.js @@ -0,0 +1,58 @@ +/***************************************************************************** + * Open MCT, Copyright (c) 2009-2016, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT 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 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. + *****************************************************************************/ + +/** + * This bundle adds the Hyperlink object type, which can be used to add hyperlinks as a domain Object type + and into display Layouts as either a button or link that can be chosen to open in either the same tab or + create a new tab to open the link in + * @namespace platform/features/hyperlink + */ +define( + [], + function () { + function HyperlinkController($scope) { + this.$scope = $scope; + } + + /**Function to analyze the location in which to open the hyperlink + @returns true if the hyperlink is chosen to open in a different tab, false if the same tab + **/ + HyperlinkController.prototype.openNewTab = function () { + if (this.$scope.domainObject.getModel().openNewTab[0] === "thisTab") { + return false; + } else { + return true; + } + }; + /**Function to specify the format in which the hyperlink should be created + @returns true if the hyperlink is chosen to be created as a button, false if a link + **/ + HyperlinkController.prototype.isButton = function () { + if (this.$scope.domainObject.getModel().displayFormat[0] === "link") { + return false; + } + return true; + }; + return HyperlinkController; + } + + ); diff --git a/platform/features/hyperlink/test/HyperlinkControllerSpec.js b/platform/features/hyperlink/test/HyperlinkControllerSpec.js new file mode 100644 index 0000000000..4348b987bb --- /dev/null +++ b/platform/features/hyperlink/test/HyperlinkControllerSpec.js @@ -0,0 +1,60 @@ +/***************************************************************************** + * Open MCT, Copyright (c) 2009-2016, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT 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 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( + ["../src/HyperlinkController"], + function (HyperlinkController) { + + describe("The controller for hyperlinks", function () { + var domainObject, + model, + controller, + link = "http://nasa.gov"; + beforeEach(function () { + domainObject = jasmine.createSpyObj( + "domainObject", + ["getModel"] + ); + model = jasmine.createSpyObj( + "getModel", + ["link","openNewTab","displayFormat"] + ); + domainObject.getModel.link = link; + domainObject.getModel.displayFormat = "button"; + domainObject.getModel.openNewTab = "thisTab"; + controller = new HyperlinkController(); + }); + it("opens a specific given link", function () { + expect(domainObject.getModel.link) + .toEqual("http://nasa.gov"); + }); + it("knows when it should open a new tab", function () { + expect(domainObject.getModel.openNewTab) + .toEqual("thisTab"); + }); + it("knows when it is a button", function () { + expect(domainObject.getModel.displayFormat) + .toEqual("button"); + }); + }); + } +); diff --git a/platform/features/layout/res/templates/frame.html b/platform/features/layout/res/templates/frame.html index a516aa9363..2a8acffd38 100644 --- a/platform/features/layout/res/templates/frame.html +++ b/platform/features/layout/res/templates/frame.html @@ -22,11 +22,13 @@
- - +
+ + +
-
- - +
+ + +
+
+ +
diff --git a/src/defaultRegistry.js b/src/defaultRegistry.js index 226cea420c..239571e3b3 100644 --- a/src/defaultRegistry.js +++ b/src/defaultRegistry.js @@ -72,6 +72,7 @@ define([ '../platform/features/listview/bundle', '../platform/features/my-items/bundle', '../platform/features/pages/bundle', + '../platform/features/hyperlink/bundle', '../platform/features/plot/bundle', '../platform/features/static-markup/bundle', '../platform/features/table/bundle', @@ -118,6 +119,7 @@ define([ 'platform/features/layout', 'platform/features/listview', 'platform/features/pages', + 'platform/features/hyperlink', 'platform/features/plot', 'platform/features/timeline', 'platform/features/table',