Sha256: 175cc8aab1bd8b2a5cd5575371bb8cc04526cc7b72fe7a110c9e7993f1034dc6

Contents?: true

Size: 1.17 KB

Versions: 6

Compression:

Stored size: 1.17 KB

Contents

class @Gallery extends Backbone.View

  initUploadButton : () ->
    @$uploadButton = @$el.find('.gallery-image-upload')
    @galleryId = @$el.find('[type="hidden"]').val()
    @galleryClassName = @$uploadButton.data('class-name')

  initCollectionView : () ->
    @collectionView = GalleryImageCollectionView.init @$el.find('.gallery-images-container'), @galleryClassName

  bindUpload : () ->
    @$uploadButton.fileupload
      dataType : 'json'
      url : @$uploadButton.data('url')
      formData :
        gallery_id : @galleryId
        class_name : @galleryClassName
      add : (e, $form) =>
        $form.submit().done @_appendUploadResult

  _appendUploadResult : (result) =>
    $.each result.gallery_images_html, (index, image_html) =>
      @collectionView.addImage $(image_html)

  @init : ($el) ->
    gallery = new this
      el : $el
    gallery.initUploadButton()
    gallery.initCollectionView()
    gallery.bindUpload()

  @initAll : () ->
    $('.gallery').each () ->
      $gallery = $(this)
      unless $gallery.data('initialized')
        Gallery.init $gallery
        $gallery.data('initialized', true)

$ ->
  $(document).on('page:load ready init-plugins', Gallery.initAll)

Version data entries

6 entries across 6 versions & 1 rubygems

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