2014-04-09 11:35:23 +00:00
|
|
|
define [
|
|
|
|
"libs/backbone"
|
|
|
|
"libs/mustache"
|
|
|
|
], () ->
|
|
|
|
SyncButtonsView = Backbone.View.extend
|
|
|
|
template: $("#syncButtonsTemplate").html()
|
|
|
|
|
|
|
|
events:
|
2014-04-09 14:24:26 +00:00
|
|
|
"click .sync-code-to-pdf": () ->
|
|
|
|
ga('send', 'event', 'editor-interaction', 'sync-code-to-pdf')
|
|
|
|
@trigger "click:sync-code-to-pdf"
|
|
|
|
"click .sync-pdf-to-code": () ->
|
|
|
|
ga('send', 'event', 'editor-interaction', 'sync-pdf-to-code')
|
|
|
|
@trigger "click:sync-pdf-to-code"
|
2014-04-09 11:35:23 +00:00
|
|
|
|
|
|
|
initialize: (options) ->
|
|
|
|
@render()
|
|
|
|
@ide = options.ide
|
|
|
|
@ide.editor.on "resize", => @repositionLeft()
|
|
|
|
|
|
|
|
render: () ->
|
|
|
|
@setElement($(@template))
|
2014-04-09 14:24:26 +00:00
|
|
|
|
|
|
|
### These keep screwing up in the UI :(
|
|
|
|
@$(".sync-code-to-pdf").tooltip({
|
|
|
|
title: "Go to code location in the output"
|
|
|
|
animate: false
|
|
|
|
placement: "top"
|
|
|
|
trigger: "hover"
|
|
|
|
delay:
|
|
|
|
show: 800
|
|
|
|
hide: 0
|
|
|
|
})
|
|
|
|
@$(".sync-pdf-to-code").tooltip({
|
|
|
|
html: true
|
|
|
|
title: "Go to output location in the code<br/>(Or double click the output)"
|
|
|
|
animate: false
|
|
|
|
placement: "bottom"
|
|
|
|
trigger: "hover"
|
|
|
|
delay:
|
|
|
|
show: 800
|
|
|
|
hide: 0
|
|
|
|
})
|
|
|
|
###
|
2014-04-09 11:35:23 +00:00
|
|
|
return @
|
|
|
|
|
2014-04-09 14:57:27 +00:00
|
|
|
hide: () ->
|
|
|
|
@hidden = true
|
|
|
|
@$el.hide()
|
2014-04-09 11:35:23 +00:00
|
|
|
|
2014-04-09 14:24:26 +00:00
|
|
|
show: () ->
|
2014-04-09 14:57:27 +00:00
|
|
|
@hidden = false
|
|
|
|
@showIfNotHiddenAndOpen()
|
|
|
|
|
|
|
|
showIfNotHiddenAndOpen: () ->
|
2014-04-09 14:24:26 +00:00
|
|
|
state = @ide.editor.$splitter.layout().readState()
|
2014-04-09 14:57:27 +00:00
|
|
|
if !@hidden and !state.east?.initClosed
|
2014-04-09 14:24:26 +00:00
|
|
|
@$el.show()
|
2014-04-09 14:57:27 +00:00
|
|
|
else
|
|
|
|
@$el.hide()
|
2014-04-09 11:35:23 +00:00
|
|
|
|
|
|
|
repositionLeft: () ->
|
|
|
|
state = @ide.editor.$splitter.layout().readState()
|
|
|
|
if state.east?
|
|
|
|
@$el.css({right: state.east.size - 8})
|
2014-04-09 14:57:27 +00:00
|
|
|
@showIfNotHiddenAndOpen();
|
2014-04-09 11:35:23 +00:00
|
|
|
|