blob: 7d574d5d27c792a978f720bb7e091599434503b6 [file] [log] [blame]
Simon Hunt0541fb82015-01-14 18:59:57 -08001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/*
18 ONOS GUI -- Our own Angular directives defined here.
19
20 @author Simon Hunt
21 */
22
23(function () {
24 'use strict';
25
26 angular.module('onosApp')
27
28 // Create a resize directive, that we can apply to elements
29 // so that they can respond to window resize events.
30 .directive('resize', ['$window', function ($window) {
31 return function (scope, element, attrs) {
32 var w = angular.element($window);
33 scope.$watch(function () {
34 return {
35 h: window.innerHeight,
36 w: window.innerWidth
37 };
38 }, function (newVal, oldVal) {
39 scope.windowHeight = newVal.h;
40 scope.windowWidth = newVal.w;
41
42 scope.resizeWithOffset = function (offH, offW) {
43 var oh = offH || 0,
44 ow = offW || 0;
45 scope.$eval(attrs.notifier);
46 return {
47 height: (newVal.h - oh) + 'px',
48 width: (newVal.w - ow) + 'px'
49 };
50 };
51 }, true);
52
53 w.bind('resize', function () {
54 scope.$apply();
55 });
56 };
57 }])
58
Simon Hunt58f23bb2015-01-16 16:32:24 -080059
60 // create icon directive, so that we can inject icons into
61 // HTML tables etc.
62 .directive('icon', ['GlyphService', function (gs) {
63 return {
64 templateUrl: 'toBeDecided-iconContext.html',
65 restrict: 'A',
66 link: function (scope, element, attrs) {
67 // TODO: implement this
68 // needs to pull out the parameters for the icon
69 // from the attributes of the element, and use those
70 // as arguments to the IconService.addIcon(...) call.
71
72
73 }
74 };
75
76
77 }]);
Simon Hunt0541fb82015-01-14 18:59:57 -080078}());