From 7c289beba588189a81b2e7bd5e600cdcb8a1773e Mon Sep 17 00:00:00 2001 From: yackob03 Date: Thu, 17 Oct 2013 14:29:47 -0400 Subject: [PATCH] Notify the tree when the container was probably resized. --- static/js/app.js | 17 +++++++++++++++++ static/js/controllers.js | 6 ++++++ static/js/graphing.js | 8 ++++++++ static/partials/view-repo.html | 2 +- 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/static/js/app.js b/static/js/app.js index 031b82c3c..375779ee0 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -117,6 +117,23 @@ quayApp = angular.module('quay', ['restangular', 'angularMoment', 'angulartics', } }; }). + directive('onresize', function ($window, $parse) { + return function (scope, element, attr) { + var fn = $parse(attr.onresize); + + var notifyResized = function() { + scope.$apply(function () { + fn(scope); + }); + }; + + angular.element($window).on('resize', null, notifyResized); + + scope.$on('$destroy', function() { + angular.element($window).off('resize', null, notifyResized); + }); + }; + }). config(['$routeProvider', '$locationProvider', '$analyticsProvider', function($routeProvider, $locationProvider, $analyticsProvider) { diff --git a/static/js/controllers.js b/static/js/controllers.js index 79d98b4ad..4de9df79f 100644 --- a/static/js/controllers.js +++ b/static/js/controllers.js @@ -313,6 +313,12 @@ function RepoCtrl($scope, Restangular, $routeParams, $rootScope, $location) { } }; + $scope.$watch('repo', function() { + if ($scope.tree) { + $scope.tree.notifyResized(); + } + }); + var listImages = function() { if ($scope.imageHistory) { return; } diff --git a/static/js/graphing.js b/static/js/graphing.js index ba371fba4..b5c1110fa 100644 --- a/static/js/graphing.js +++ b/static/js/graphing.js @@ -136,6 +136,14 @@ ImageHistoryTree.prototype.draw = function(container) { }; +/** + * Redraws the image history to fit the new size. + */ +ImageHistoryTree.prototype.notifyResized = function() { + console.log('Image history container resized.'); +}; + + /** * Sets the current tag displayed in the tree. */ diff --git a/static/partials/view-repo.html b/static/partials/view-repo.html index 834bdb918..1d6af5704 100644 --- a/static/partials/view-repo.html +++ b/static/partials/view-repo.html @@ -83,7 +83,7 @@ -
+