2 * Licensed under the Apache License, Version 2.0 (the "License");
3 * you may not use this file except in compliance with the License.
4 * You may obtain a copy of the License at
6 * http://www.apache.org/licenses/LICENSE-2.0
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the License for the specific language governing permissions and
12 * limitations under the License.
20 .controller('HeaderController', HeaderController);
22 HeaderController.$inject = ['$location'];
25 * TestAPI Header Controller
26 * This controller is for the header template which contains the site
29 function HeaderController($location) {
32 ctrl.isActive = isActive;
33 ctrl.isCatalogActive = isCatalogActive;
35 /** Whether the Navbar is collapsed for small displays. */
36 ctrl.navbarCollapsed = true;
39 * This determines whether a button should be in the active state based
42 function isActive(viewLocation) {
43 var path = $location.path().substr(0, viewLocation.length);
44 if (path === viewLocation) {
45 // Make sure "/" only matches when viewLocation is "/".
46 if (!($location.path().substr(0).length > 1 &&
47 viewLocation.length === 1 )) {
54 /** This determines the active state for the catalog dropdown. Type
55 * parameter should be passed in to specify if the catalog is the
58 function isCatalogActive(type) {
59 return ctrl.isActive('/' + type + '_vendors')
60 || ctrl.isActive('/' + type + '_products');