Merge pull request #267 from sharelatex/pr-log-dropdown

"Other logs & files" dropdown / dropup
This commit is contained in:
Paulo Jorge Reis 2016-07-06 16:06:10 +01:00 committed by GitHub
commit efacd9e7f2
3 changed files with 33 additions and 5 deletions

View file

@ -145,7 +145,7 @@ div.full-size.pdf(ng-controller="PdfController")
p.entry-content(ng-show="entry.content") {{ entry.content.trim() }} p.entry-content(ng-show="entry.content") {{ entry.content.trim() }}
p p
.pull-right .files-dropdown-container
a.btn.btn-default.btn-sm( a.btn.btn-default.btn-sm(
href, href,
tooltip="#{translate('clear_cached_files')}", tooltip="#{translate('clear_cached_files')}",
@ -155,12 +155,15 @@ div.full-size.pdf(ng-controller="PdfController")
) )
i.fa.fa-trash-o i.fa.fa-trash-o
|   |  
div.dropdown(style="display: inline-block;", dropdown) div.files-dropdown(
ng-class="shouldDropUp ? 'dropup' : 'dropdown'"
dropdown
)
a.btn.btn-default.btn-sm( a.btn.btn-default.btn-sm(
href href
dropdown-toggle dropdown-toggle
) )
| !{translate("other_logs_and_files")} | !{translate("other_logs_and_files")}
span.caret span.caret
ul.dropdown-menu.dropdown-menu-right ul.dropdown-menu.dropdown-menu-right
li(ng-repeat="file in pdf.outputFiles") li(ng-repeat="file in pdf.outputFiles")

View file

@ -15,6 +15,22 @@ define [
$scope.shouldShowLogs = false $scope.shouldShowLogs = false
$scope.wikiEnabled = window.wikiEnabled; $scope.wikiEnabled = window.wikiEnabled;
# view logic to check whether the files dropdown should "drop up" or "drop down"
$scope.shouldDropUp = false
logsContainerEl = document.querySelector ".pdf-logs"
filesDropdownEl = logsContainerEl?.querySelector ".files-dropdown"
# get the top coordinate of the files dropdown as a ratio (to the logs container height)
# logs container supports scrollable content, so it's possible that ratio > 1.
getFilesDropdownTopCoordAsRatio = () ->
filesDropdownEl?.getBoundingClientRect().top / logsContainerEl?.getBoundingClientRect().height
$scope.$watch "shouldShowLogs", (shouldShow) ->
if shouldShow
$scope.$applyAsync () ->
$scope.shouldDropUp = getFilesDropdownTopCoordAsRatio() > 0.65
# log hints tracking # log hints tracking
$scope.trackLogHintsLearnMore = () -> $scope.trackLogHintsLearnMore = () ->
event_tracking.sendCountly "logs-hints-learn-more" event_tracking.sendCountly "logs-hints-learn-more"

View file

@ -122,7 +122,7 @@
font-weight: 700; font-weight: 700;
.fa { .fa {
display: none; opacity: 0;
} }
} }
.entry-message { .entry-message {
@ -138,7 +138,7 @@
&:hover .line-no { &:hover .line-no {
color: inherit; color: inherit;
.fa { .fa {
display: inline-block; opacity: 1;
} }
} }
@ -284,3 +284,12 @@
margin-top: 20px; margin-top: 20px;
} }
} }
.files-dropdown-container {
.pull-right();
position: relative;
}
.files-dropdown {
display: inline-block;
}