Auto resize project list to always fit in screen

This commit is contained in:
James Allen 2014-07-08 17:47:20 +01:00
parent ff7b7cdd20
commit 4423471b1a
4 changed files with 19 additions and 1 deletions

View file

@ -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

View file

@ -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)
}

View file

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

View file

@ -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