MainAreaManager.coffee 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. define () ->
  2. class MainAreaManager
  3. constructor: (@ide, @el) ->
  4. @$iframe = $('#imageArea')
  5. @$loading = $('#loading')
  6. @$currentArea = $('#loading')
  7. @areas = {}
  8. addArea: (options) ->
  9. @areas ||= {}
  10. @areas[options.identifier] = options.element
  11. options.element.hide()
  12. @el.append(options.element)
  13. removeArea: (identifier) ->
  14. @areas ||= {}
  15. if @areas[identifier]?
  16. if @$currentArea == @areas[identifier]
  17. delete @$currentArea
  18. @areas[identifier].remove()
  19. delete @areas[identifier]
  20. getAreaElement: (identifier) ->
  21. @areas[identifier]
  22. setIframeSrc: (src)->
  23. $('#imageArea iframe').attr 'src', src
  24. change : (type, complete)->
  25. if @areas[type]?
  26. @$currentArea.hide() if @$currentArea?
  27. @areas[type].show 0, =>
  28. @ide.layoutManager.refreshHeights()
  29. if complete?
  30. complete()
  31. @$currentArea = @areas[type]
  32. else
  33. # Deprecated system
  34. switch type
  35. when 'iframe'
  36. if(@$iframe.attr('id')!=@$currentArea.attr('id'))
  37. @$iframe.show()
  38. @$currentArea.hide()
  39. @$currentArea = @$iframe
  40. break
  41. when 'loading'
  42. if(@$loading.attr('id')!=@$currentArea.attr('id'))
  43. @$currentArea.hide()
  44. @$loading.show()
  45. @$currentArea = @$loading
  46. break