[VID-6] Initial rebase push
[vid.git] / vid-app-common / src / main / webapp / app / vid / scripts / directives / extensionsDirective.js
1 /*-\r
2  * ============LICENSE_START=======================================================\r
3  * VID\r
4  * ================================================================================\r
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
6  * ================================================================================\r
7  * Licensed under the Apache License, Version 2.0 (the "License");\r
8  * you may not use this file except in compliance with the License.\r
9  * You may obtain a copy of the License at\r
10  * \r
11  *      http://www.apache.org/licenses/LICENSE-2.0\r
12  * \r
13  * Unless required by applicable law or agreed to in writing, software\r
14  * distributed under the License is distributed on an "AS IS" BASIS,\r
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  * See the License for the specific language governing permissions and\r
17  * limitations under the License.\r
18  * ============LICENSE_END=========================================================\r
19  */\r
20 \r
21 "use strict";\r
22 \r
23 /*\r
24  * Defines "extensions" to standard Angular directives. Provides attributes that\r
25  * can be included in HTML tags.\r
26  * \r
27  * SYNTAX: ngx-enabled="true | false"\r
28  * \r
29  * Enables / disables an element. Currently only supports button elements that\r
30  * include the "button" element. This extension was added since the similar\r
31  * standard Angular "ng-disabled" attribute does not handle buttons that use the\r
32  * ECOMP styling.\r
33  * \r
34  * SYNTAX: ngx-visible="true | false"\r
35  * \r
36  * Sets an element to visible / hidden. Different from ng-show / ng-hide as\r
37  * follows:\r
38  * \r
39  * ng-show=false or ng-hide=true - Element is completely hidden.\r
40  * \r
41  * ngx-visible=false - Element is not displayed. However, a blank area is\r
42  * displayed where the element would display if ngx-visible is set to true.\r
43  */\r
44 \r
45 appDS2.directive('ngxEnabled', function() {\r
46     return {\r
47         restrict : "A",\r
48         link : function(scope, element, attrs) {\r
49             attrs.$observe("ngxEnabled", function(value) {\r
50                 if (attrs.attButton === "") {\r
51                     if (value === "true") {\r
52                         element.attr("btn-type", "primary").removeClass(\r
53                                 "button--inactive").addClass("button--primary")\r
54                                 .prop('disabled', false);\r
55                     } else {\r
56                         element.attr("btn-type", "disabled").removeClass(\r
57                                 "button--primary").addClass("button--inactive")\r
58                                 .prop('disabled', true);\r
59                     }\r
60                 }\r
61             });\r
62         }\r
63     }\r
64 });\r
65 \r
66 appDS2.directive('ngxVisible', function() {\r
67     return {\r
68         restrict : "A",\r
69         link : function(scope, element, attrs) {\r
70             attrs.$observe("ngxVisible", function(value) {\r
71                 if (value === "true") {\r
72                     element.css("visibility", "visible");\r
73                 } else {\r
74                     element.css("visibility", "hidden");\r
75                 }\r
76             });\r
77         }\r
78     }\r
79 });\r