Initial OpenECOMP policy/engine commit
[policy/engine.git] / ecomp-sdk-app / src / main / webapp / app / policyApp / policy-models / Editor / src / js / directives / directives.js
1 /*-
2  * ============LICENSE_START=======================================================
3  * ECOMP Policy Engine
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 (function(angular) {
22     'use strict';
23     var app = angular.module('abs');
24
25     app.directive('angularFilemanager', ['$parse', 'fileManagerConfig', function($parse, fileManagerConfig) {
26         return {
27             restrict: 'EA',
28             templateUrl: fileManagerConfig.tplPath + '/main.html'
29         };
30     }]);
31
32     app.directive('ngFile', ['$parse', function($parse) {
33         return {
34             restrict: 'A',
35             link: function(scope, element, attrs) {
36                 var model = $parse(attrs.ngFile);
37                 var modelSetter = model.assign;
38
39                 element.bind('change', function() {
40                     scope.$apply(function() {
41                         modelSetter(scope, element[0].files);
42                     });
43                 });
44             }
45         };
46     }]);
47
48     app.directive('ngRightClick', ['$parse', function($parse) {
49         return function(scope, element, attrs) {
50             var fn = $parse(attrs.ngRightClick);
51             element.bind('contextmenu', function(event) {
52                 scope.$apply(function() {
53                     event.preventDefault();
54                     fn(scope, {$event: event});
55                 });
56             });
57         };
58     }]);
59     
60 })(angular);