Sha256: 98f0d49924b20257f76e36309b2e01b6b285eb5179f30e52ba4ccd7c86b1e241

Contents?: true

Size: 1.96 KB

Versions: 5

Compression:

Stored size: 1.96 KB

Contents

$(document).on 'direct-uploads:start', 'form', (e) ->
  $(this).find('.customfile').addClass('loading')

$(document).on 'direct-uploads:end', 'form', (e) ->
  $(this).find('.customfile').removeClass('loading')

$(document).on 'change', 'input[type="file"]', (e) ->
  $form = $(this).parents('form')
  $form.find('input[type="submit"]').click()

$(document).on 'click', '.organize-switch', (e) ->
  $items = $('.gallery .infinite-scroll .item')
  disabled = $items.draggable('option', 'disabled')
  if disabled 
    $(this).addClass('button-success')
    $(this).text($(this).attr('data-done-organizing'))
    $(this).prepend('<i class="icon icon-random"></i>')
  else 
    $(this).removeClass('button-success')
    $(this).text($(this).attr('data-organize-images'))
    $(this).prepend('<i class="icon icon-random"></i>')
  $items.draggable('option', 'disabled', !disabled)
  e.preventDefault()

ready = ->
  $('.media-folder').droppable(
    drop: (event, ui) ->
      url = $(this).attr('data-add-to-media-folder-url')
      image_id = $(ui.draggable).attr('data-image-id')

      $.ajax
        url: url,
        type: 'PUT',
        data: {
          image_id: image_id
        },
        dataType: 'json',
        success: (result) =>
          $(ui.draggable).addClass('dropped').fadeOut()
          imageCount = parseInt($(this).find('.media-folder-thumbnail').attr('data-badge'))
          imgSrc = $(ui.draggable).find('img').attr('src')

          $(this).removeClass('dropping')
          $(this).find('.media-folder-thumbnail').attr('data-badge', imageCount + 1)
          $(this).find('.media-folder-thumbnail img').attr('src', imgSrc)

    over: (event, ui) ->
      $(ui.draggable).addClass('dropping')

      $(this).addClass('dropping')
    out: (event, ui) ->
      $(ui.draggable).removeClass('dropping')

      $(this).removeClass('dropping')
  )

  $('.gallery .infinite-scroll .item').draggable(
    revert: 'invalid',
    disabled: true
  )

$(document).on 'turbolinks:load', ready

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spina-2.0.2 app/assets/javascripts/spina/admin/media_gallery.coffee
spina-2.0.1 app/assets/javascripts/spina/admin/media_gallery.coffee
spina-2.0.0 app/assets/javascripts/spina/admin/media_gallery.coffee
spina-2.0.0.beta app/assets/javascripts/spina/admin/media_gallery.coffee
spina-2.0.0.alpha app/assets/javascripts/spina/admin/media_gallery.coffee