Sha256: 12e3a912a080d53a25ee84e577a65cc9a36c78ad483cc44467f1217b134da1b7

Contents?: true

Size: 1.63 KB

Versions: 77

Compression:

Stored size: 1.63 KB

Contents

$(document).on 'click', '.asset-box-dialog', (event) ->
  event.preventDefault()

  obj = $(event.currentTarget)
  asset_box = obj.closest('.asset-box-input')
  modal = obj.siblings('.asset-box-modal')

  return false unless modal

  iframe = modal.find('iframe')
  iframe.attr('height', $(window).height() * 0.75)

  unless asset_box.data('dialog-initialized')
    iframe.contents().on 'click', '.attachment-insert', (event) ->
      event.preventDefault()

      $.ajax
        url: "/s3_uploads/#{$(this).data('asset-id')}"
        type: 'PUT'
        data:
          skip_update: true
          attachable_type: asset_box.data('attachable-type')
          attachable_id: asset_box.data('attachable-id')
          attachable_object_name: asset_box.data('attachable-object-name')
          attachment_style: asset_box.data('attachment-style')
          attachment_actions: asset_box.data('attachment-actions')
          aws_acl: asset_box.data('aws-acl')
          box: asset_box.data('box')
        async: true
        success: (data) ->
          asset_box.find('.attachments').prepend($(data))

          limit = asset_box.data('limit')

          asset_box.find("input.asset-box-remove").each (index) ->
            if "#{$(this).val()}" == '1'  # If we're going to delete it...
              $(this).closest('.attachment').hide()
              limit = limit + 1
              return

            if index >= limit
              $(this).closest('.attachment').hide()
            else
              $(this).closest('.attachment').show()

      if asset_box.data('limit') == 1 then modal.modal('hide')

  asset_box.data('dialog-initialized', true)
  modal.modal()

Version data entries

77 entries across 77 versions & 1 rubygems

Version Path
effective_assets-1.12.2 app/assets/javascripts/effective_assets/asset_box_dialog.js.coffee
effective_assets-1.12.1 app/assets/javascripts/effective_assets/asset_box_dialog.js.coffee
effective_assets-1.12.0 app/assets/javascripts/effective_assets/asset_box_dialog.js.coffee
effective_assets-1.11.5 app/assets/javascripts/effective_assets/asset_box_dialog.js.coffee
effective_assets-1.11.4 app/assets/javascripts/effective_assets/asset_box_dialog.js.coffee
effective_assets-1.11.3 app/assets/javascripts/effective_assets/asset_box_dialog.js.coffee
effective_assets-1.11.2 app/assets/javascripts/effective_assets/asset_box_dialog.js.coffee
effective_assets-1.11.1 app/assets/javascripts/effective_assets/asset_box_dialog.js.coffee
effective_assets-1.11.0 app/assets/javascripts/effective_assets/asset_box_dialog.js.coffee
effective_assets-1.10.1 app/assets/javascripts/effective_assets/asset_box_dialog.js.coffee
effective_assets-1.10.0 app/assets/javascripts/effective_assets/asset_box_dialog.js.coffee
effective_assets-1.9.14 app/assets/javascripts/effective_assets/asset_box_dialog.js.coffee
effective_assets-1.9.13 app/assets/javascripts/effective_assets/asset_box_dialog.js.coffee
effective_assets-1.9.12 app/assets/javascripts/effective_assets/asset_box_dialog.js.coffee
effective_assets-1.9.11 app/assets/javascripts/effective_assets/asset_box_dialog.js.coffee
effective_assets-1.9.10 app/assets/javascripts/effective_assets/asset_box_dialog.js.coffee
effective_assets-1.9.9 app/assets/javascripts/effective_assets/asset_box_dialog.js.coffee
effective_assets-1.9.8 app/assets/javascripts/effective_assets/asset_box_dialog.js.coffee
effective_assets-1.9.7 app/assets/javascripts/effective_assets/asset_box_dialog.js.coffee
effective_assets-1.9.6 app/assets/javascripts/effective_assets/asset_box_dialog.js.coffee