Internals.coffee 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. class Internals extends Class
  2. constructor: (@sidebar) ->
  3. @tag = null
  4. @opened = false
  5. if window.top.location.hash == "#internals"
  6. setTimeout (=> @open()), 10
  7. createHtmltag: ->
  8. @when_loaded = $.Deferred()
  9. if not @container
  10. @container = $("""
  11. <div class="internals-container">
  12. <div class="internals"><div class="internals-middle">
  13. <div class="mynode"></div>
  14. <div class="peers">
  15. <div class="peer"><div class="line"></div><a href="#" class="icon">\u25BD</div></div>
  16. </div>
  17. </div></div>
  18. </div>
  19. """)
  20. @container.appendTo(document.body)
  21. @tag = @container.find(".internals")
  22. open: =>
  23. @createHtmltag()
  24. @sidebar.fixbutton_targety = @sidebar.page_height
  25. @stopDragY()
  26. onOpened: =>
  27. @sidebar.onClosed()
  28. @log "onOpened"
  29. onClosed: =>
  30. $(document.body).removeClass("body-internals")
  31. stopDragY: =>
  32. # Animate sidebar and iframe
  33. if @sidebar.fixbutton_targety == @sidebar.fixbutton_inity
  34. # Closed
  35. targety = 0
  36. @opened = false
  37. else
  38. # Opened
  39. targety = @sidebar.fixbutton_targety - @sidebar.fixbutton_inity
  40. @onOpened()
  41. @opened = true
  42. # Revent sidebar transitions
  43. if @tag
  44. @tag.css("transition", "0.5s ease-out")
  45. @tag.css("transform", "translateY(#{targety}px)").one transitionEnd, =>
  46. @tag.css("transition", "")
  47. if not @opened
  48. @log "cleanup"
  49. # Revert body transformations
  50. @log "stopdrag", "opened:", @opened, targety
  51. if not @opened
  52. @onClosed()
  53. window.Internals = Internals