       @_addToGallery object, image
     @
 
-  _addToGallery: (data, image) ->
-    return unless data.source
-
-    cid = ++counter
-
-    data.thumbnail = data.source unless data.thumbnail
-    @images[cid] = data
-    @length++
-
-    if image
-      showFirstImage = (event, cid) =>
-        event.stopPropagation()
-        event.preventDefault()
-        @show cid
-
-      image.addClass('choco-item').click (event) -> showFirstImage event, cid
-
-      preload = new Image()
-      preload.src = data.thumbnail
-      preload.onload = ->
-        image.after templates['image-hover'].replace '{{cid}}', cid
-
-        popover = $('[data-pid=' + cid + ']').css
-          'width':      image.width()
-          'height':     image.height()
-          'margin-top': '-' + image.height() + 'px'
-
-        popover.click (event) -> showFirstImage event, cid
-
   ###
    Показать изображение на большом экране
   ###
   show: (cid) ->
-    cid = @getImageFromUri() unless cid?
+    cid = @_getImageFromUri() unless cid?
     cid = 1 if cid <= 0
     throw 'Image not found' unless @images[cid]?
 

          when 39    # Right arrow
            @next()

    @add images if images

  _prepareActionFor: (element) ->
    method = if @options.actions[element] in existActions then @options.actions[element] else false
    if method
      verify = @[element].attr 'class'
      @[element].click (event) => @[method]() if $(event.target).hasClass verify
      if @options.actions[element] is 'close'
        @[element].bind 'mouseenter mouseleave', (event) => @_hoverCloseButton()
    @

  _hoverCloseButton: ->
    @overlay.find('.choco-close').toggleClass 'hover'

  getImageFromUri: ->
    hash = window.location.hash
    if hash then toInt hash.replace('#image', '') else 0

  ###
   Добавляем список изображений для работы в галереи

                         .replace('{{thumbnail}}', image.thumbnail)
                         .replace('{{title}}', if image.title then ' title="' + image.title + '"' else '')

    @thumbnails.html(content).find('.choco-thumbnail').click ->
      _this.open toInt $(@).attr('data-cid')

    @overlay.find('.choco-thumbnails-toggle').click ->
      current = _this.images[_this.current]
      method  = if _this.thumbnails.hasClass 'hide' then 'removeClass' else 'addClass'

