 
 
   ns.openPreviewDialog = (file, settings) ->
+    # hide current opened dialog and open new one
     oldDialogPr = currentDialogPr
     currentDialogPr = null
     settings = $.extend({}, settings, {

    })
    uploadcare.openDialog(file, 'preview', settings).always ->
      currentDialogPr = oldDialogPr


  # files - null, or File object, or array of File objects, or FileGroup object

    if ns.isDialogOpened()
      if e.which == 27  # Escape
        e.stopImmediatePropagation()
        # close only topmost dialog
        currentDialogPr?.reject()

  currentDialogPr = null
