GUI -- Further tweaking of the background map loading code, to properly align the map in the view.
- still WIP, as we need to invoke a resized() callback in the controller so that the view can also respond to the event.
Change-Id: I55fa5e52c70e208924ad22d389e2002c66cb37ef
diff --git a/web/gui/src/main/webapp/app/onos.js b/web/gui/src/main/webapp/app/onos.js
index 8f4a618..a8669db 100644
--- a/web/gui/src/main/webapp/app/onos.js
+++ b/web/gui/src/main/webapp/app/onos.js
@@ -44,6 +44,37 @@
angular.module('onosApp', moduleDependencies)
+ // Create a resize directive, that we can apply to elements to
+ // respond to window resize events.
+ .directive('resize', ['$window', function ($window) {
+ return function (scope, element, attrs) {
+ var w = angular.element($window);
+ scope.$watch(function () {
+ return {
+ h: window.innerHeight,
+ w: window.innerWidth
+ };
+ }, function (newVal, oldVal) {
+ scope.windowHeight = newVal.h;
+ scope.windowWidth = newVal.w;
+
+ scope.resizeWithOffset = function (offH, offW) {
+ var oh = offH || 0,
+ ow = offW || 0;
+ scope.$eval(attrs.notifier);
+ return {
+ height: (newVal.h - oh) + 'px',
+ width: (newVal.w - ow) + 'px'
+ };
+ };
+ }, true);
+
+ w.bind('resize', function () {
+ scope.$apply();
+ });
+ };
+ }])
+
.controller('OnosCtrl', [
'$log', '$route', '$routeParams', '$location',
'KeyService', 'ThemeService', 'GlyphService',