Avoid duplicating code

This commit is contained in:
Chrystal Griffiths 2018-10-08 17:50:10 +01:00
parent d51549c4f0
commit 849c5253c7
3 changed files with 19 additions and 18 deletions

View file

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

View file

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

View file

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