Sha256: e2f8f2aeaf35ae4090034181b51253ec2a6d523f7a0f14bbb09812eb0de68242

Contents?: true

Size: 892 Bytes

Versions: 6

Compression:

Stored size: 892 Bytes

Contents

class @GalleryImageCollectionView extends Backbone.View

  initImages : (className) ->
    @images = new GalleryImageCollection()
    @images.setClassName(className)
    @$el.find('.gallery-image').each (index, image) =>
      @_initImage $(image)

  initSort : () ->
    sortUrl = @$el.data('sortable-url')
    if sortUrl
      @images.setSortUrl sortUrl
      @$el.sortable
        stop : () =>
          @images.sort @_getSortedImages()

  addImage : ($image) ->
    @_initImage $image
    @$el.append $image

  _getSortedImages : () =>
    images = []
    @$el.find('.gallery-image').each (index, el) ->
      images.push $(el).data('id')
    images

  _initImage : ($image) ->
    @images.add GalleryImageView.init($image)

  @init : ($el, className) ->
    collectionView = new this
      el : $el
    collectionView.initImages className
    collectionView.initSort()
    collectionView

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rademade_admin-0.2.2 app/assets/javascripts/rademade_admin/app/gallery/image/collection-view.coffee
rademade_admin-0.2.1 app/assets/javascripts/rademade_admin/app/gallery/image/collection-view.coffee
rademade_admin-0.2.0 app/assets/javascripts/rademade_admin/app/gallery/image/collection-view.coffee
rademade_admin-0.1.6 app/assets/javascripts/rademade_admin/app/gallery/image/collection-view.coffee
rademade_admin-0.1.5 app/assets/javascripts/rademade_admin/app/gallery/image/collection-view.coffee
rademade_admin-0.1.4 app/assets/javascripts/rademade_admin/app/gallery/image/collection-view.coffee