From 88564ea126692d97ded10063aff8dcf098534c27 Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Tue, 28 Jun 2016 15:48:11 +0100 Subject: [PATCH 1/3] Dynamically determine if the files dropdown should drop up or drop down. --- services/web/app/views/project/editor/pdf.jade | 8 ++++++-- .../ide/pdf/controllers/PdfController.coffee | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/services/web/app/views/project/editor/pdf.jade b/services/web/app/views/project/editor/pdf.jade index 091831a22d..66cea0f09e 100644 --- a/services/web/app/views/project/editor/pdf.jade +++ b/services/web/app/views/project/editor/pdf.jade @@ -151,12 +151,16 @@ div.full-size.pdf(ng-controller="PdfController") ) i.fa.fa-trash-o |   - div.dropdown(style="display: inline-block;", dropdown) + div.files-dropdown( + style="display: inline-block;", + ng-class="shouldDropUp ? 'dropup' : 'dropdown'" + dropdown + ) a.btn.btn-default.btn-sm( href dropdown-toggle ) - | !{translate("other_logs_and_files")} + | !{translate("other_logs_and_files")} span.caret ul.dropdown-menu.dropdown-menu-right li(ng-repeat="file in pdf.outputFiles") diff --git a/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee b/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee index 610915ec3a..50b1b40aa0 100644 --- a/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee +++ b/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee @@ -15,6 +15,22 @@ define [ $scope.shouldShowLogs = false $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 + if ace.require("ace/lib/useragent").isMac $scope.modifierKey = "Cmd" else From a6d184358f026adefb180eb0f3e62fd3953bdde1 Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Tue, 28 Jun 2016 15:51:50 +0100 Subject: [PATCH 2/3] Avoid inline-styles. --- services/web/app/views/project/editor/pdf.jade | 3 +-- services/web/public/stylesheets/app/editor/pdf.less | 9 +++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/services/web/app/views/project/editor/pdf.jade b/services/web/app/views/project/editor/pdf.jade index 66cea0f09e..77bc7cc379 100644 --- a/services/web/app/views/project/editor/pdf.jade +++ b/services/web/app/views/project/editor/pdf.jade @@ -141,7 +141,7 @@ div.full-size.pdf(ng-controller="PdfController") p.entry-content(ng-show="entry.content") {{ entry.content.trim() }} p - .pull-right + .files-dropdown-container a.btn.btn-default.btn-sm( href, tooltip="#{translate('clear_cached_files')}", @@ -152,7 +152,6 @@ div.full-size.pdf(ng-controller="PdfController") i.fa.fa-trash-o |   div.files-dropdown( - style="display: inline-block;", ng-class="shouldDropUp ? 'dropup' : 'dropdown'" dropdown ) diff --git a/services/web/public/stylesheets/app/editor/pdf.less b/services/web/public/stylesheets/app/editor/pdf.less index 2d147c2f69..7e9b1ff05c 100644 --- a/services/web/public/stylesheets/app/editor/pdf.less +++ b/services/web/public/stylesheets/app/editor/pdf.less @@ -284,3 +284,12 @@ margin-top: 20px; } } + +.files-dropdown-container { + .pull-right(); + position: relative; +} + + .files-dropdown { + display: inline-block; + } From 54ec75d36ab38ef2e81e63df94b306b77cf0d16b Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Wed, 6 Jul 2016 15:55:36 +0100 Subject: [PATCH 3/3] Avoid line-breaks when showing the log icon. --- services/web/public/stylesheets/app/editor/pdf.less | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/web/public/stylesheets/app/editor/pdf.less b/services/web/public/stylesheets/app/editor/pdf.less index 7e9b1ff05c..a4d2eeb214 100644 --- a/services/web/public/stylesheets/app/editor/pdf.less +++ b/services/web/public/stylesheets/app/editor/pdf.less @@ -122,7 +122,7 @@ font-weight: 700; .fa { - display: none; + opacity: 0; } } .entry-message { @@ -138,7 +138,7 @@ &:hover .line-no { color: inherit; .fa { - display: inline-block; + opacity: 1; } }