|
@@ -1,17 +1,19 @@
|
|
|
define [
|
|
define [
|
|
|
"utils/Modal"
|
|
"utils/Modal"
|
|
|
"pdf/CompiledView"
|
|
"pdf/CompiledView"
|
|
|
|
|
+ "pdf/SyncButtonsView"
|
|
|
"libs/latex-log-parser"
|
|
"libs/latex-log-parser"
|
|
|
"libs/jquery.storage"
|
|
"libs/jquery.storage"
|
|
|
"libs/underscore"
|
|
"libs/underscore"
|
|
|
"libs/backbone"
|
|
"libs/backbone"
|
|
|
-], (Modal, CompiledView, LogParser) ->
|
|
|
|
|
|
|
+], (Modal, CompiledView, SyncButtonsView, LogParser) ->
|
|
|
class PdfManager
|
|
class PdfManager
|
|
|
templates:
|
|
templates:
|
|
|
pdfLink: $("#pdfSideBarLinkTemplate").html()
|
|
pdfLink: $("#pdfSideBarLinkTemplate").html()
|
|
|
|
|
|
|
|
constructor: (@ide) ->
|
|
constructor: (@ide) ->
|
|
|
_.extend @, Backbone.Events
|
|
_.extend @, Backbone.Events
|
|
|
|
|
+ @createSyncButtons()
|
|
|
@createPdfPanel()
|
|
@createPdfPanel()
|
|
|
@ide.editor.aceEditor.commands.addCommand
|
|
@ide.editor.aceEditor.commands.addCommand
|
|
|
name: "compile",
|
|
name: "compile",
|
|
@@ -35,6 +37,15 @@ define [
|
|
|
else
|
|
else
|
|
|
@switchToSplitView()
|
|
@switchToSplitView()
|
|
|
|
|
|
|
|
|
|
+ createSyncButtons: () ->
|
|
|
|
|
+ unless @ide.userSettings.pdfViewer == "native"
|
|
|
|
|
+ @syncButtonsView = new SyncButtonsView(ide: @ide)
|
|
|
|
|
+ @syncButtonsView.on "click:sync-code-to-pdf", () =>
|
|
|
|
|
+ @syncToPdf()
|
|
|
|
|
+ @syncButtonsView.on "click:sync-pdf-to-code", () =>
|
|
|
|
|
+ @syncToCode()
|
|
|
|
|
+ @syncButtonsView.hide()
|
|
|
|
|
+
|
|
|
switchToFlatView: (options = {showPdf: false}) ->
|
|
switchToFlatView: (options = {showPdf: false}) ->
|
|
|
@teardownSplitView()
|
|
@teardownSplitView()
|
|
|
@setupFlatView()
|
|
@setupFlatView()
|
|
@@ -85,6 +96,11 @@ define [
|
|
|
|
|
|
|
|
@view.undelegateEvents()
|
|
@view.undelegateEvents()
|
|
|
@view.delegateEvents()
|
|
@view.delegateEvents()
|
|
|
|
|
+
|
|
|
|
|
+ @ide.editor.$splitter.append(
|
|
|
|
|
+ @syncButtonsView?.$el
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
setTimeout(@ide.layoutManager.resizeAllSplitters, 100)
|
|
setTimeout(@ide.layoutManager.resizeAllSplitters, 100)
|
|
|
|
|
|
|
|
teardownSplitView: () ->
|
|
teardownSplitView: () ->
|
|
@@ -112,7 +128,9 @@ define [
|
|
|
doneCompiling = _.once =>
|
|
doneCompiling = _.once =>
|
|
|
@compiling = false
|
|
@compiling = false
|
|
|
@view.doneCompiling()
|
|
@view.doneCompiling()
|
|
|
|
|
+ @syncButtonsView?.show()
|
|
|
setTimeout doneCompiling, 1000 * 60
|
|
setTimeout doneCompiling, 1000 * 60
|
|
|
|
|
+
|
|
|
if !@ide.project.get("rootDoc_id")?
|
|
if !@ide.project.get("rootDoc_id")?
|
|
|
new Modal
|
|
new Modal
|
|
|
title: "No root document selected"
|
|
title: "No root document selected"
|
|
@@ -123,6 +141,7 @@ define [
|
|
|
}]
|
|
}]
|
|
|
else if !@compiling
|
|
else if !@compiling
|
|
|
@view.onCompiling()
|
|
@view.onCompiling()
|
|
|
|
|
+ @syncButtonsView?.hide()
|
|
|
@compiling = true
|
|
@compiling = true
|
|
|
@ide.socket.emit "pdfProject", opts, (err, pdfExists, outputFiles) =>
|
|
@ide.socket.emit "pdfProject", opts, (err, pdfExists, outputFiles) =>
|
|
|
@compiling = false
|
|
@compiling = false
|
|
@@ -142,6 +161,7 @@ define [
|
|
|
else
|
|
else
|
|
|
@view.unsetPdf()
|
|
@view.unsetPdf()
|
|
|
@view.showLog()
|
|
@view.showLog()
|
|
|
|
|
+ @syncButtonsView?.hide()
|
|
|
|
|
|
|
|
if outputFiles?
|
|
if outputFiles?
|
|
|
@view.showOutputFileDownloadLinks(outputFiles)
|
|
@view.showOutputFileDownloadLinks(outputFiles)
|
|
@@ -213,6 +233,13 @@ define [
|
|
|
}]
|
|
}]
|
|
|
|
|
|
|
|
syncToCode: (e) ->
|
|
syncToCode: (e) ->
|
|
|
|
|
+ if !e?
|
|
|
|
|
+ e = @view.getPdfPosition()
|
|
|
|
|
+ return if !e?
|
|
|
|
|
+ # It's not clear exactly where we should sync to if it was directly
|
|
|
|
|
+ # clicked on, but a little bit down from the very top seems best.
|
|
|
|
|
+ e.y = e.y + 80
|
|
|
|
|
+
|
|
|
$.ajax {
|
|
$.ajax {
|
|
|
url: "/project/#{@ide.project_id}/sync/pdf"
|
|
url: "/project/#{@ide.project_id}/sync/pdf"
|
|
|
data:
|
|
data:
|