From d51549c4f0be55d3888125bc8de71ca85d647964 Mon Sep 17 00:00:00 2001 From: Chrystal Griffiths Date: Fri, 5 Oct 2018 11:19:20 +0100 Subject: [PATCH 1/3] Use ng-if to switch between pdf and editor --- services/web/app/views/project/editor/editor.pug | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/services/web/app/views/project/editor/editor.pug b/services/web/app/views/project/editor/editor.pug index fda0fa6446..93368ceba4 100644 --- a/services/web/app/views/project/editor/editor.pug +++ b/services/web/app/views/project/editor/editor.pug @@ -102,7 +102,6 @@ div.full-size( ) i.synctex-control-icon div.full-size( - ng-if="ui.pdfLayout == 'flat'" - ng-show="ui.view == 'pdf'" + ng-if="ui.pdfLayout == 'flat' && ui.view == 'pdf'" ) include ./pdf From 849c5253c732cb4fb8afe49f891a87bec6ceb5d6 Mon Sep 17 00:00:00 2001 From: Chrystal Griffiths Date: Mon, 8 Oct 2018 17:50:10 +0100 Subject: [PATCH 2/3] Avoid duplicating code --- services/web/app/views/project/editor/pdf.pug | 4 ++-- services/web/public/coffee/ide.coffee | 17 +++++++++++++++++ .../ide/pdf/controllers/PdfController.coffee | 16 ---------------- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/services/web/app/views/project/editor/pdf.pug b/services/web/app/views/project/editor/pdf.pug index 44410a44a8..f0d1a11666 100644 --- a/services/web/app/views/project/editor/pdf.pug +++ b/services/web/app/views/project/editor/pdf.pug @@ -106,7 +106,7 @@ div.full-size.pdf(ng-controller="PdfController") | #{translate("code_check_failed")} a( href, - ng-click="switchToFlatLayout()" + ng-click="switchToFlatLayout('pdf')" ng-show="ui.pdfLayout == 'sideBySide'" tooltip=translate('full_screen') tooltip-placement="bottom" @@ -116,7 +116,7 @@ div.full-size.pdf(ng-controller="PdfController") i.full-screen a( href, - ng-click="switchToSideBySideLayout()" + ng-click="switchToSideBySideLayout('editor')" ng-show="ui.pdfLayout == 'flat'" tooltip=translate('split_screen') tooltip-placement="bottom" diff --git a/services/web/public/coffee/ide.coffee b/services/web/public/coffee/ide.coffee index 1b9eda57d6..12f6dba2ce 100644 --- a/services/web/public/coffee/ide.coffee +++ b/services/web/public/coffee/ide.coffee @@ -190,6 +190,23 @@ define [ ide.localStorage = localStorage ide.browserIsSafari = false + + $scope.switchToFlatLayout = (view) -> + $scope.ui.pdfLayout = 'flat' + $scope.ui.view = view + ide.localStorage "pdf.layout", "flat" + + $scope.switchToSideBySideLayout = (view) -> + $scope.ui.pdfLayout = 'sideBySide' + $scope.ui.view = view + localStorage "pdf.layout", "split" + + if pdfLayout = localStorage("pdf.layout") + $scope.switchToSideBySideLayout() if pdfLayout == "split" + $scope.switchToFlatLayout() if pdfLayout == "flat" + else + $scope.switchToSideBySideLayout() + try userAgent = navigator.userAgent ide.browserIsSafari = ( diff --git a/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee b/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee index 001178c5dd..a9e99f3d84 100644 --- a/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee +++ b/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee @@ -588,22 +588,6 @@ define [ {doc, line} = data ide.editorManager.openDoc(doc, gotoLine: line) - $scope.switchToFlatLayout = () -> - $scope.ui.pdfLayout = 'flat' - $scope.ui.view = 'pdf' - ide.localStorage "pdf.layout", "flat" - - $scope.switchToSideBySideLayout = () -> - $scope.ui.pdfLayout = 'sideBySide' - $scope.ui.view = 'editor' - localStorage "pdf.layout", "split" - - if pdfLayout = localStorage("pdf.layout") - $scope.switchToSideBySideLayout() if pdfLayout == "split" - $scope.switchToFlatLayout() if pdfLayout == "flat" - else - $scope.switchToSideBySideLayout() - App.factory "synctex", ["ide", "$http", "$q", (ide, $http, $q) -> # enable per-user containers by default perUserCompile = true From 7ae39a0f84db57c7f918f1521e1dc1b9b742f91e Mon Sep 17 00:00:00 2001 From: Chrystal Griffiths Date: Tue, 9 Oct 2018 10:30:24 +0100 Subject: [PATCH 3/3] Revert to ng-show --- services/web/app/views/project/editor/editor.pug | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/web/app/views/project/editor/editor.pug b/services/web/app/views/project/editor/editor.pug index 93368ceba4..fda0fa6446 100644 --- a/services/web/app/views/project/editor/editor.pug +++ b/services/web/app/views/project/editor/editor.pug @@ -102,6 +102,7 @@ div.full-size( ) i.synctex-control-icon div.full-size( - ng-if="ui.pdfLayout == 'flat' && ui.view == 'pdf'" + ng-if="ui.pdfLayout == 'flat'" + ng-show="ui.view == 'pdf'" ) include ./pdf