 $ ->
   methods =
     init: (options) ->
-      settings = _.extend
-        open: false
-        multiselect: false
+      settings = $.extend true,
+        {}
       , options
 
       throw "host isn't defined" unless settings.host
       throw "tenant isn't defined" unless settings.tenant
 
       @each ->
-        $uploader = $(@)
+        $uploader = $ @
         uploader = $uploader.data()
 
         uploaderId = $.md5(Math.random())[0..3]


        getUrl = ->
          # "Живой" префикс
          prefix = settings.prefix or $uploader.data('prefix')
          throw "prefix isn't defined" unless prefix?

          multiselect = settings.multiselect or $uploader.data('multiselect')
          type = settings.type or $uploader.data('type')

          "#{settings.host}/#
            tenant/#{settings.tenant}/

            prefix/#{prefix}
          ".replace /\ /g, ''

        getIframe = ->
          modalId = settings.modalId ? $uploader.data('modalId')
          if modalId
            $uploaderIframe = $("##{modalId}").find('.js-uploader-iframe')
          else
            $uploaderIframe = $uploader.find('.js-uploader-iframe')
          $uploaderIframe.first()

        initIframe = ->
          $iframe = getIframe()
          if $iframe.length
            iframeTemplate = _.template '''
              <iframe width='<%= width %>' height='<%= height %>' src='<%= src %>' frameborder='0'></iframe>
            '''

            $iframe.html iframeTemplate $.extend
              src: getUrl()
              width: '100%'
              height: 500
            , $iframe.data()

        openUploader = ->
          $iframe = getIframe()
          if $iframe.length
            $iframe.closest('div.modal').modal('show') if $.fn.modal?
            initIframe()
          else
            popupWindow = open getUrl(), 'NMD Media Lib', 'scrollbars=1, width=800, height=500'
            popupWindow.focus()

        if settings.open ? $uploader.data('open')
          openUploader()
        else
          $uploader.find('.js-uploader-open').on 'click', (e) ->
