SyncButtonsView.coffee 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. define [
  2. "libs/backbone"
  3. "libs/mustache"
  4. ], () ->
  5. SyncButtonsView = Backbone.View.extend
  6. template: $("#syncButtonsTemplate").html()
  7. events:
  8. "click .sync-code-to-pdf": () ->
  9. ga('send', 'event', 'editor-interaction', 'sync-code-to-pdf')
  10. @trigger "click:sync-code-to-pdf"
  11. "click .sync-pdf-to-code": () ->
  12. ga('send', 'event', 'editor-interaction', 'sync-pdf-to-code')
  13. @trigger "click:sync-pdf-to-code"
  14. initialize: (options) ->
  15. @render()
  16. @ide = options.ide
  17. @ide.editor.on "resize", => @repositionLeft()
  18. render: () ->
  19. @setElement($(@template))
  20. ### These keep screwing up in the UI :(
  21. @$(".sync-code-to-pdf").tooltip({
  22. title: "Go to code location in the output"
  23. animate: false
  24. placement: "top"
  25. trigger: "hover"
  26. delay:
  27. show: 800
  28. hide: 0
  29. })
  30. @$(".sync-pdf-to-code").tooltip({
  31. html: true
  32. title: "Go to output location in the code<br/>(Or double click the output)"
  33. animate: false
  34. placement: "bottom"
  35. trigger: "hover"
  36. delay:
  37. show: 800
  38. hide: 0
  39. })
  40. ###
  41. return @
  42. hide: () ->
  43. @hidden = true
  44. @$el.hide()
  45. show: () ->
  46. @hidden = false
  47. @showIfNotHiddenAndOpen()
  48. showIfNotHiddenAndOpen: () ->
  49. state = @ide.editor.$splitter.layout().readState()
  50. if !@hidden and !state.east?.initClosed
  51. @$el.show()
  52. else
  53. @$el.hide()
  54. repositionLeft: () ->
  55. state = @ide.editor.$splitter.layout().readState()
  56. if state.east?
  57. @$el.css({right: state.east.size - 8})
  58. @showIfNotHiddenAndOpen();