SideBarManager.coffee 987 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. define () ->
  2. class SideBarManager
  3. constructor: (@ide, @el) ->
  4. addLink: (options) ->
  5. @elements ||= {}
  6. @elements[options.identifier] = options.element
  7. if options.before and @elements[options.before]
  8. options.element.insertBefore @elements[options.before]
  9. else if options.after and @elements[options.after]
  10. options.element.insertAfter @elements[options.after]
  11. else if options.prepend
  12. @el.prepend options.element
  13. else
  14. @el.append options.element
  15. removeLink: (identifier) ->
  16. @elements ||= {}
  17. if @elements[identifier]?
  18. @elements[identifier].remove()
  19. delete @elements[identifier]
  20. selectLink: (identifier) ->
  21. @selectElement(@elements[identifier].find("li"))
  22. selectElement: (selector, callback)->
  23. # This method is deprecated and will eventually be replaced
  24. # by selectLink
  25. if $(selector).length
  26. @deselectAll()
  27. $(selector).addClass('selected')
  28. deselectAll: () ->
  29. $('.selected').removeClass('selected')