 
   currentDialogPr = null
 
-  ns.isDialogOpened = -> 
+  ns.isDialogOpened = ->
     currentDialogPr != null
 
   ns.closeDialog = ->

  class Dialog
    constructor: (@settings, files, tab) ->

      if files 
        unless $.isArray(files)
          files = [files]
      else
        files = []

      @dfd = $.Deferred()
      @dfd.always => 
        @__closeDialog()

      @content = $(tpl('dialog'))
        .hide()
        .appendTo('body')
        .addClass(if @settings.multiple then 'uploadcare-dialog-multiple')
      
      @files = new utils.CollectionOfPromises()

      @__bind()

    __prepareTabs: (tab) ->
      @addTab 'preview'
      @__hideTab 'preview'

      @addTab tabName for tabName in @settings.tabs
      @switchTab(tab || @settings.tabs[0])

