Просмотр исходного кода

Auto resize project list to always fit in screen

James Allen 12 лет назад
Родитель
Сommit
4423471b1a

+ 1 - 0
services/web/app/views/project/list.jade

@@ -233,6 +233,7 @@ block content
 									ul.list-unstyled.project-list.structured-list(
 										select-all-list,
 										ng-if="projects.length > 0",
+										max-height="windowHeight - 290",
 										ng-cloak
 									)
 										li.container-fluid

+ 11 - 0
services/web/public/coffee/directives/maxHeight.coffee

@@ -0,0 +1,11 @@
+define [
+	"base"
+], (App) ->
+	App.directive "maxHeight", () ->
+		return {
+			restrict: "A"
+			link: (scope, element, attrs) ->
+				scope.$watch attrs.maxHeight, (value) ->
+					if value?
+						element.css("max-height": value)
+		}

+ 1 - 0
services/web/public/coffee/main.coffee

@@ -11,6 +11,7 @@ define [
 	"directives/fineUpload"
 	"directives/onEnter"
 	"directives/selectAll"
+	"directives/maxHeight"
 	"filters/formatDate"
 ], () ->
 	angular.bootstrap(document.body, ["SharelatexApp"])

+ 6 - 1
services/web/public/coffee/main/project-list.coffee

@@ -50,7 +50,7 @@ define [
 
 	]
 
-	App.controller "ProjectPageController", ($scope, $modal, $q, queuedHttp) ->
+	App.controller "ProjectPageController", ($scope, $modal, $q, $window, queuedHttp) ->
 		$scope.projects = window.data.projects
 		$scope.visibleProjects = $scope.projects
 		$scope.tags = window.data.tags
@@ -58,6 +58,11 @@ define [
 		$scope.selectedProjects = []
 		$scope.filter = "all"
 
+		$scope.windowHeight = $window.innerHeight
+		angular.element($window).bind "resize", () ->
+			$scope.windowHeight = $window.innerHeight
+			$scope.$apply()
+
 		# Allow tags to be accessed on projects as well
 		projectsById = {}
 		for project in $scope.projects